diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-07 00:24:03 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-07 00:24:03 +0300 |
commit | ed39daa568d162617a183497010d70a55a38ae73 (patch) | |
tree | 313c1caef8b42ab1800f5c1cef8dece9116fbd0d /doc/grecs_malloc.3 | |
parent | 18d7db07b9f369901300bf664d07d4b39032ce64 (diff) | |
download | grecs-ed39daa568d162617a183497010d70a55a38ae73.tar.gz grecs-ed39daa568d162617a183497010d70a55a38ae73.tar.bz2 |
Redo memory management (2).
* src/grecs.h (grecs_free_fun): New extern.
(grecs_free): New proto.
* src/format.c: Use grecs_free where appropriate.
* src/grecs-lex.l: Likewise.
* src/preproc.c: Likewise.
* src/tree.c: Likewise.
* src/lookup.c (parse_label): Use grecs_value_list_create.
* src/mem.c: Initialize hooks with the default values.
(grecs_free_fun): New hook.
(grecs_free): New function.
* doc/grecs_malloc.3: Document grecs_free.
* doc/grecs_parse.3: Document the recent changes.
* doc/grecs_strdup.3: Update.
Diffstat (limited to 'doc/grecs_malloc.3')
-rw-r--r-- | doc/grecs_malloc.3 | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/doc/grecs_malloc.3 b/doc/grecs_malloc.3 index 58cc9a0..1d52eca 100644 --- a/doc/grecs_malloc.3 +++ b/doc/grecs_malloc.3 @@ -16,7 +16,7 @@ .\" This file is part of SLB. .\" Copyright (C) 2011 Sergey Poznyakoff .\" -.TH GRECS_MALLOC 3 "May 3, 2011" "GRECS" "Grecs User Reference" +.TH GRECS_MALLOC 3 "May 7, 2011" "GRECS" "Grecs User Reference" .SH NAME grecs_malloc, grecs_zalloc, grecs_calloc, grecs_realloc \- Allocate dynamic memory for \fBGrecs\fR. @@ -32,12 +32,16 @@ dynamic memory for \fBGrecs\fR. .br .BI "void *grecs_realloc(void " "*ptr" ", size_t " "size" ); .br +.BI "void grecs_free(void " "*ptr" ); +.br .BI "void grecs_alloc_die(void);" .sp .BI "void *(*grecs_malloc_fun)(size_t " "size" ); .br .BI "void *(*grecs_realloc_fun)(void " "*ptr" ", size_t " "size" ); .br +.BI "void (*grecs_free_fun)(void " "*ptr" ); +.br .BI "void (*grecs_alloc_die_fun)(void);" .SH DESCRIPTION .PP @@ -76,14 +80,24 @@ allocates bytes and returns a pointer to the allocated memory. The memory is set to zero. .PP -If \fBgrecs_malloc_fun\fR is not \fINULL\fR, it will be used by -\fBgrecs_malloc\fR, \fBgrecs_calloc\fR and \fBgrecs_zalloc\fR to -allocate new memory chunk. If it is not set, these function use -\fBmalloc(3)\fR. +.BR grecs_free () +frees the memory space pointed to by \fBptr\fR, which must have been +returned by a previous call to one of the memory allocation functions +discussed above. +.PP +The \fBgrecs_malloc_fun\fR hook is used \fBgrecs_malloc\fR, +\fBgrecs_calloc\fR and \fBgrecs_zalloc\fR to allocate new memory +chunk. By default it points to +.BR malloc (3). +.PP +Similarly, the \fBgrecs_realloc_fun\fR, is used by +\fBgrecs_realloc\fR function. By default it points to +.BR realloc (3). .PP -Similarly, the \fBgrecs_realloc_fun\fR, if set, is used by -\fBgrecs_realloc\fR function. Otherwise, this function uses -\fBrealloc(3)\fR. +The \fBgrecs_free_fun\fR is used by +.BR grecs_free (). +By default it points to +.BR free (3). .PP These hooks provide a way for the calling program to use its custom memory allocation routines. |