Search code examples
ccalloc

determine length of calloc array of TCHARs (not string length)


I have this code:

TCHAR *sRes;
sRes = (TCHAR *) calloc(16384, sizeof(TCHAR));
DWORD dwRes = sizeof(sRes);

dwRes is always 8, and of course _tcslen(sRes) is always 0.

I am looking for 16384.


Solution

  • There is no supported mechanism for obtaining size of a block allocated with malloc or calloc. If you call HeapAlloc instead you may call HeapSize thereafter.