Path: utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari!aplcen!uunet!mcsun!ukc!stl!dsr From: dsr@stl.stc.co.uk (David Riches) Newsgroups: comp.lang.c Subject: FREE Message-ID: <2714@stl.stc.co.uk> Date: 26 Feb 90 11:15:01 GMT Sender: news@stl.stc.co.uk Reply-To: dsr@stl.stc.co.uk (David Riches) Organization: STC Technology Limited, London Road, Harlow, Essex, UK Lines: 24 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@stl.stc.co.uk ARPA: dsr%stl.stc.co.uk@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