Path: utzoo!utgpu!water!watmath!clyde!bellcore!tness7!tness1!sugar!ficc!peter From: peter@ficc.UUCP (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: Malloc problems Summary: Sounds like AllocRemember Message-ID: <839@.UUCP> Date: 1 Jun 88 14:22:04 GMT References: <690008@hpfelg.HP.COM> <13100010@bucc2> <5482@bloom-beacon.MIT.EDU> Organization: SCADA Lines: 55 This "memory group" thing sounds like "AllocRemember", a routine that comes as part of the Amiga Intuition library: struct RememberKey *Memory; Memory = 0; ... space = AllocRemember(&Memory, size, flags); ... morespace = AllocRemember(&Memory, size, flags); ... FreeRemember(&Memory, TRUE); This has the result of allocating the memory on a linked list. You get the effect of the memory spaces for free. When you call FreeRemember it trashes all the memory linked on that particular RememberKey. Implementation? Easy: struct memkey { struct memkey *nextkey; char data[0]; }; mallocremember(key, size) struct memkey **key; int size; { struct memkey *ptr; ptr = malloc(sizeof(struct memkey *)+size); ptr->nextkey = *key; *key = ptr; return ptr->data; } freeremember(key) struct memkey **key; { while(*key) { ptr = (*key)->nextkey; free(*key); *key = ptr; } } -- -- Peter da Silva, Ferranti International Controls Corporation. -- Phone: 713-274-5180. Remote UUCP: uunet!nuchat!sugar!peter.