Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Re: Malloc problems Message-ID: <1988May25.211600.1541@utzoo.uucp> Organization: U of Toronto Zoology References: <690008@hpfelg.HP.COM>, <13100010@bucc2> Date: Wed, 25 May 88 21:16:00 GMT There is no need to mess with the insides of malloc for this. It is really pretty easy to implement a scheme in which you get an "area" by calling newarea() and then get data "within" the area by calling, say, areaalloc() with the area and the size you want. The area is in fact a data structure which keeps pointers to everything you allocate through it. areaalloc() just invokes malloc() and adds a pointer to the result to the area. You can then deallocate everything in the area by calling a function that just goes through the area calling free() on everything. Note that the "area" doesn't actually correspond to a contiguous block of storage, despite its name. You can add arbitrary bookkeeping to the area functions easily. The major advantage is this stuff can be fully portable, which the insides of malloc (and hence, changes to the insides of malloc) are *NOT*.