|
Value: { \
uint32_t tempsize = nelems * sizeof(cast); \
if (ptr == NULL) \
{ \
ptr = (cast *)phCalloc(nelems,sizeof(cast)); \
phCHECK_NULLPTR(ptr,"phMalloc", \
"phMalloc failed(nelems:%u,size:%u)",nelems,tempsize); \
cursize = tempsize; \
} \
else if (cursize != tempsize)\
{ \
ptr = (cast *)phRealloc(ptr,tempsize); \
phCHECK_NULLPTR(ptr,"phRealloc", \
"phRealloc failed(nelems:%u,size:%u)",nelems,tempsize); \
cursize = tempsize; \
} \
}
Will resize to the memory but won't zeroize the memory. It will grow or shrink to the requested memory. a.k.a: phDALLOC_NELEMS_RESIZE
Resize only if more memory is needed. This may consume more memory, but there are no leaks and the need to phRealloc memory over and over when toggling from large to small to large is reduced
Definition at line 269 of file phMemory.h. |