calloc & realloc

Here’s my problem:

I’m creating some arrays using the calloc function.

At some point later in my program I may need to increase the size of these arrays.

I’m wandering if it is possible to reallocate memory for arrays created with calloc, with realloc ?

It says you can in my C programming book, but it gives no examples of how to do it.

Any help would be much appreciated.

You can use realloc with calloc just as with malloc…
I think it goes like this:

char * test;


//Not sure if the realloc call´s syntax is correct look it up in the help…

However realloc is a bitch…Using it has several dangers…The biggest problem is that there is no guarantee that the new allocated space starts at the same memory-address than the old one…Which means that all pointers that are assigned to the array in previous code need to be reassigned after realloc in case the memory location has changed(very likely)…If you don´t reassign them you can get some serios crash…


[This message has been edited by XBCT (edited 08-06-2000).]