S
serrand
Hello all,
i wonder if we can know the size of a variable from a pointer :
static void *my_free_hook (void *ptr, const void *caller)
{
size_t sz;
/* bla bla bla */
/* HOW CAN I DETERMINE SIZE OF *ptr ? */
printf ("size of freed memory : %u", sz);
}
sizeof (ptr) is the size of a pointer (4 on my system)... and sizeof(*ptr) is the size of the first byte = 1 ...
all idea welcome ...
Xavier
i wonder if we can know the size of a variable from a pointer :
static void *my_free_hook (void *ptr, const void *caller)
{
size_t sz;
/* bla bla bla */
/* HOW CAN I DETERMINE SIZE OF *ptr ? */
printf ("size of freed memory : %u", sz);
}
sizeof (ptr) is the size of a pointer (4 on my system)... and sizeof(*ptr) is the size of the first byte = 1 ...
all idea welcome ...
Xavier