This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

is it possible to size a pointer's target?


 
 Hi Everyone,
 
I'm interested in whether it is possible to get the size of a variable a
pointer is pointing at.
 
I have a function that accepts a char * pointer. This can either be stack or
heap memory but more typically stack where I see it.
 
It would help me tremendously if I could figure out the size of the variable
at the other end of the pointer. I can't think of a way to do this
unfortunately.
 
strlen won't work as the variable is null when passed in
sizeof(*ptr) returns 1, even though the memory is larger
 
sizeof(ptr) returns 4 (on my 32 bit machine) of course
 
Can anyone think of how to do this, or am I out of luck?
 
Thank you in advance,
Andrew



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]