diff options
author | Paul Smith <psmith@gnu.org> | 2013-05-04 17:38:53 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2013-05-04 17:38:53 -0400 |
commit | 3e67695034a1e235cbcf2c70d283fe0cd6c77427 (patch) | |
tree | ac9c0c1179e567213ed25f3161b64fc0254e24c7 /loadapi.c | |
parent | 54eddcc711207137cbace67d1f922a7690bb90e8 (diff) | |
download | make-3e67695034a1e235cbcf2c70d283fe0cd6c77427.tar.gz |
Add memory allocation cleanup to loadable objects.
Add gmk_alloc() and gmk_free() functions so loadable objects can access our
memory model. Also provide a more extensive example in the manual.
Diffstat (limited to 'loadapi.c')
-rw-r--r-- | loadapi.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -20,6 +20,20 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ #include "variable.h" #include "dep.h" +/* Allocate a buffer in our context, so we can free it. */ +char * +gmk_alloc (unsigned int len) +{ + return xmalloc (len); +} + +/* Free a buffer returned by gmk_expand(). */ +void +gmk_free (char *s) +{ + free (s); +} + /* Evaluate a buffer as make syntax. Ideally eval_buffer() will take const char *, but not yet. */ void @@ -31,7 +45,7 @@ gmk_eval (const char *buffer, const gmk_floc *floc) } /* Expand a string and return an allocated buffer. - Caller must free() this buffer. */ + Caller must call gmk_free() with this buffer. */ char * gmk_expand (const char *ref) { |