Afficher un message
Vieux 18/10/2007, 10h02   #1
Guillaume Dargaud
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Is realloc good form ?

Hello all,
I have a 'good practice' question.
Lately I've been using a lot of functions such as this:

void Func(int Size, double *Array) {
static double *Transformed=NULL;
Transformed=realloc(Transformed, Size*sizeof(double));
// Do something from Array to Transformed
}

Now if the value of Size changes a lot between calls, the resulting prog is
poorly optimized (it reallocates each time). I'm ok with that.
Ignoring the fact that the memory is never freed, if the value of Size
changes seldom, does the call to realloc wastes time then ?
--
Guillaume Dargaud
http://www.gdargaud.net/


  Réponse avec citation
 
Page generated in 0,04291 seconds with 9 queries