If I define
char a[] = "Blub";
I can get the memory size of 'a' with the sizeof operator.
But if I call a function 'tst(a)' then inside of 'tst' the sizeof operator gives me the size of the address of 'a'.
If I define
char* b = malloc(somesize);
The 'sizeof(b)' too is the size of the address of 'b'.
'a' is a constant string while 'b' is allocated on the heap.
It should be possible to differentiate between the two string types by
BOOL IsHeapStr(char* x) { return _heap_validate(x); }
But how can I find the memory size they own, 5 for 'a' and somesize for 'b'?
You can't.
For the allocated value you can use _msize function, and if pointing to a valid allocated memory chunk you will get a value that is not exactly what you have allocated, but generally bigger.
Passing a static array on the called function side you always see a char * which size id 4 or 8 bytes (32 or 64 bits compilation).
Is there something like a heap pointer (or better two heap pointers, a small heap pointer and a large heap pointer)?