S
shilpi.harpavat
Hi,
I am trying to allocate more memory if the following condition is true.
IS it free of memory leaks??
if(numLevels >= numAlloc) {
char **oldLevels = levels;
long *oldOrder = order;
numAlloc *= 10;
levels = (char **) calloc(numAlloc, sizeof(char *));
order = (long *) calloc(numAlloc, sizeof(long));
for(i = 0; i < numLevels; i++) {
levels = oldLevels;
order = oldOrder;
}
free(oldLevels);
free(oldOrder);
}
Thanks in advance
Shilpi
I am trying to allocate more memory if the following condition is true.
IS it free of memory leaks??
if(numLevels >= numAlloc) {
char **oldLevels = levels;
long *oldOrder = order;
numAlloc *= 10;
levels = (char **) calloc(numAlloc, sizeof(char *));
order = (long *) calloc(numAlloc, sizeof(long));
for(i = 0; i < numLevels; i++) {
levels = oldLevels;
order = oldOrder;
}
free(oldLevels);
free(oldOrder);
}
Thanks in advance
Shilpi