malloc schemes
Chris Torek
chris at mimsy.UUCP
Tue May 24 23:09:28 AEST 1988
>In article <13100010 at bucc2> brian at bucc2.UUCP writes:
>>... After a call to malloc is made, a mark() function can be called
>>to set a code in this field. Later, a function called free_group()
>>frees all the blocks with a specific code. ...
In article <5482 at bloom-beacon.MIT.EDU> raeburn at athena.mit.edu
(Ken Raeburn) writes:
>How about combining these steps? ...
> area create_area (void);
> void * allocate (size_t size, area a);
> void release (void * ptr);
> void free_area (area a);
This seems a much nicer interface. I would suggest that if you wanted
something like `programmer' and `project' fields, that you augment it
to, e.g.,
area a_create(char *identifier);
void *a_alloc(size_t size, area a);
void a_free1(void *ptr);
void a_freeall(area a);
The `identifier' would merely be stored somewhere for debugging
purposes:
void a_snapshot(FILE *outf);
...
a_snapshot(stderr);
might produce a list of all allocated blocks, their sizes, and
their identifiers.
If you decide it would be worthwhile, it would be easy enough
to add a `find named area' routine:
area a_find(char *identifier);
which would make freeing someone else's trash easier:
a_freeall(a_find("jow bloe/lawnmower data"));
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list