FREE

David Riches dsr at stl.stc.co.uk
Mon Feb 26 22:15:01 AEST 1990


We're writing a tool which requires memory management.
We have a routine which allocates memory in the following
fashion :-
  #define NE_ARR_MALLOC(y,n) ((y *) malloc ((unsigned) ((n) * (sizeof(y))))) 

Which will allocate space for n of y.

The question then arises as how best to free this space?
In most cases only the pointer to the space is known but will the
following free up all the space :-
  #define NE_ARR_FREE(x)     { free((char *) sizeof(x)); x = 0; }

What happens to other references which might be pointing half way
down the list for instance? 

Does anyone have any routines for memory management within C?

   Dave Riches
   PSS:    dsr at stl.stc.co.uk
   ARPA:   dsr%stl.stc.co.uk at earn-relay.ac.uk
   Smail:  Software Design Centre, (Dept. 103, T2 West), 
	   STC Technology Ltd., London Road,
	   Harlow, Essex. CM17 9NA.  England
   Phone:  +44 (0)279-29531 x2496



More information about the Comp.lang.c mailing list