Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > How to Check the content of the memory?

Reply
Thread Tools

How to Check the content of the memory?

 
 
RJ
Guest
Posts: n/a
 
      12-15-2005
Hi All,

Suppose i have a double pointer, how do I check the content of that
pointer is a 8/16/24/32 bit data?

Any suggestion!!

Thanks,
Raja

 
Reply With Quote
 
 
 
 
Neelesh Bodas
Guest
Posts: n/a
 
      12-15-2005

RJ wrote:
> Hi All,
>
> Suppose i have a double pointer, how do I check the content of that
> pointer is a 8/16/24/32 bit data?
>
> Any suggestion!!
>


double *d;
sizeof(*d); // size in bytes
sizeof(*d) * CHAR_BITS // size in bits

 
Reply With Quote
 
 
 
 
mlimber
Guest
Posts: n/a
 
      12-15-2005
RJ wrote:
> Suppose i have a double pointer, how do I check the content of that
> pointer is a 8/16/24/32 bit data?


Please clarify:

When you say "double pointer", do you mean double* or something like
int**? If the former, double can be other sizes, too (e.g., 64 bit
data).

When you say "check the content of that pointer", do you mean check the
size of the data it points to, check the address contained by the
pointer itself, or check the value of the data it points to?

In any case, the size of built-in types (ints, doubles, pointers, etc.)
are implementation-specific, and you should check your platform
documentation to see what the sizes are in your case.

Cheers! --M

 
Reply With Quote
 
Neelesh Bodas
Guest
Posts: n/a
 
      12-15-2005

RJ wrote:
> Hi All,
>
> Suppose i have a double pointer, how do I check the content of that
> pointer is a 8/16/24/32 bit data?
>
> Any suggestion!!
>
> Thanks,
> Raja


 
Reply With Quote
 
Neelesh Bodas
Guest
Posts: n/a
 
      12-15-2005
RJ wrote:
> Hi All,
>
> Suppose i have a double pointer, how do I check the content of that
> pointer is a 8/16/24/32 bit data?
>

double *p;
sizeof(*p); // returns the number of bytes
sizeof(*p) * CHAR_BITS // returns the size in bits

 
Reply With Quote
 
RJ
Guest
Posts: n/a
 
      12-16-2005
>When you say "double pointer", do you mean double* or something like
>int**? If the former, double can be other sizes, too (e.g., 64 bit
>data).


Sorry for the confusion. Its a double* p.

>When you say "check the content of that pointer", do you mean check the
>size of the data it points to, check the address contained by the
>pointer itself, or check the value of the data it points to?


For example,

unsigned long* lp=0xFFF;
if I have RGB value in *lp and the RGB is 444 format. Only 12 bits are
used out of 32 bit. Remaining 20 bits padded with 0.

unsigned long* lp=0xFFFFFF;
Like if i have RGB of 888, then only 24 bit used and remaining 8 bits
padded with 0.

So my question is how to find a pointer content is used only 'n' number
of bytes and remaining 'm' number of bytes are padded to 0.
ie.,In generic how to calculate n and m?

Thanks again.
Raja

 
Reply With Quote
 
RJ
Guest
Posts: n/a
 
      12-16-2005
>So my question is how to find a pointer content is used only 'n' number
>of bytes and remaining 'm' number of bytes are padded to 0.
>ie.,In generic how to calculate n and m?


So my question is how to find a pointer content is used only 'n' number

of bits remaining 'm' number of bits are padded to 0.
ie.,In generic how to calculate n and m?

 
Reply With Quote
 
Michiel.Salters@tomtom.com
Guest
Posts: n/a
 
      12-16-2005
RJ wrote:
> unsigned long* lp=0xFFF;
> if I have RGB value in *lp and the RGB is 444 format. Only 12 bits are
> used out of 32 bit. Remaining 20 bits padded with 0.


Sure, but what if you have black? That's 0x000. 12 bits used, but those
bits are just as 0 as the other 20 bits.

In general, you can't. You can check the number of bits in the format
mask, if such a thing exists. The number of bits in x, nb(x) is found
by nb(x) = x%2 + nb(x/2).

HTH,
Michiel Salters

 
Reply With Quote
 
mlimber
Guest
Posts: n/a
 
      12-16-2005
RJ wrote:
> >When you say "double pointer", do you mean double* or something like
> >int**? If the former, double can be other sizes, too (e.g., 64 bit
> >data).

>
> Sorry for the confusion. Its a double* p.


First of all, the fact that it's a pointer (whether of type double* or
unsigned long* or whatever) is irrelevant based on what you say below.
You seem to care about the pointee, not the pointer.

In the case of doubles, the floating point format is
implementation-dependent. There are a certain number of bits allocated
for the exponent and a certain number for the mantissa, but those
numbers are not standard. Check your platform documentation for the
floating point format.

> >When you say "check the content of that pointer", do you mean check the
> >size of the data it points to, check the address contained by the
> >pointer itself, or check the value of the data it points to?

>
> For example,
>
> unsigned long* lp=0xFFF;
> if I have RGB value in *lp and the RGB is 444 format. Only 12 bits are
> used out of 32 bit. Remaining 20 bits padded with 0.
>
> unsigned long* lp=0xFFFFFF;
> Like if i have RGB of 888, then only 24 bit used and remaining 8 bits
> padded with 0.
>
> So my question is how to find a pointer content is used only 'n' number
> of bytes and remaining 'm' number of bytes are padded to 0.
> ie.,In generic how to calculate n and m?


As the other responder pointed out, you might get into trouble with
certain values, depending on how you use the number of non-zero bits.
Usually, in image processing applications, you just need to keep track
of how many bits are valid and only work on those. That means that you
may need to pass a mask or bit count (and perhaps other relevant
information) around to your functions along with the pixels, but that's
just part of the game.

In case you do have a legitimate use for such information, you can
easily calculate it:

unsigned CountBitsUsed( unsigned long val )
{
for( int n=sizeof(unsigned long)-1; n > 0; --n )
if( 0 != (val & (1<<n)) )
return n+1;
return 0;
}

Cheers! --M

 
Reply With Quote
 
Jim Langston
Guest
Posts: n/a
 
      12-18-2005
"RJ" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi All,
>
> Suppose i have a double pointer, how do I check the content of that
> pointer is a 8/16/24/32 bit data?
>
> Any suggestion!!
>
> Thanks,
> Raja
>


What you seem to be asking (after reading the follow ups) is if you have a
pointer to some unknown data, how can you find out what the size is of the
unknown data.

Basically, the pointer won't tell you. The pointer points to a spot in
memory. How you declare the pointer suggests what type of data should be
there. That is, if you have an int* it should be pointing to an integer
value which is x bytes on your platform.

But you seem to be specifically interested in video memory, RGB data. Well,
this totally depends on the format of the data you are looking at. If you
are looking at video memory, it depends on what display resolution your
monitor video card is set to. If you are looking at bitmap information, it
would depend on the format of the bitmap.

For video memory, you need to find out the resolution the video card is
currently set to. This is dependant on your OS. For bitmap information, it
depends on the format of the bitmap. I believe this is also OS independant.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz ASP .Net 6 06-09-2010 01:54 PM
Error: "Content controls can only be used in a content page" J.Edwards ASP .Net 0 01-20-2006 11:43 AM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">? TheKeith HTML 20 10-29-2003 11:56 AM



Advertisments