Any way to retreive the memory amount currently allocated for the pointer value?
Not in the sense you're looking for, no.
In the language sense, the amount of memory allocated for the pointer value (in question) is, of course, sizeof(unsigned char *)
. This (again, of course) does in no way correlate with the size of the memory block the pointer is pointing to. A pointer simply holds no such information.
If you (for some reason) cannot pass the size information alongside with the pointer, you must decide a value of unsigned char
to signify the end of the memory block (and assign that value to the end of the memory block). (This is how strings work in C). The only way to find the length of the block is to loop through the values.
Why do you have a pointer to unsigned char, if it really points to char? By the way, char buff
is hardly a buffer, as it only holds a single value of char.