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/


.



Relevant Pages

  • Re: segfault w/ block, but not file scope
    ... void foo{ ... possess by-reference arguments, even ordinary local variables ... The "value" of the array is a pointer to the array's ...
    (comp.lang.c)
  • Re: Mergesort Vs Quicksort
    ... given as variable-length records packed end-to-end in one array, ... int scmp(const void *a, const void *b) ... int (*compar)(const void *, const void *)) ...
    (comp.programming)
  • Re: Mergesort Vs Quicksort
    ... given as variable-length records packed end-to-end in one array, ... int (*compar)(const void *, const void *)) ...
    (comp.programming)
  • Re: PHP - I give up.
    ... /* Compares A and B, given auxiliary data AUX, and returns a ... typedef int algo_predicate_func (const void *data, ... SIZE bytes each, using COMPARE for comparisons. ... first element in ARRAY that matches TARGET, ...
    (comp.programming)
  • Newbie question about class member functions...
    ... "How to do figure out how much of my array is ... // Function to open a playlist file and read it into an array ... cout << endl ... void editFile() ...
    (comp.lang.cpp)