summaryrefslogtreecommitdiff
path: root/gnumake.h
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-05-04 17:38:53 -0400
committerPaul Smith <psmith@gnu.org>2013-05-04 17:38:53 -0400
commit3484c9675a8a09904e08e00bf6842d834cd0201d (patch)
treeac9c0c1179e567213ed25f3161b64fc0254e24c7 /gnumake.h
parenta0c5d0c63f6801ca16865d04faa223cea440d2c0 (diff)
downloadgunmake-3484c9675a8a09904e08e00bf6842d834cd0201d.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 'gnumake.h')
-rw-r--r--gnumake.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/gnumake.h b/gnumake.h
index a6308fe..168f370 100644
--- a/gnumake.h
+++ b/gnumake.h
@@ -26,22 +26,26 @@ typedef struct
unsigned long lineno;
} gmk_floc;
+
#ifdef _WIN32
-# ifdef MAIN
-# define GMK_EXPORT __declspec(dllexport)
-# else
+# ifndef GMK_EXPORT
# define GMK_EXPORT __declspec(dllimport)
# endif
#else
# define GMK_EXPORT
#endif
+/* Free memory returned by the gmk_expand() function. */
+void GMK_EXPORT gmk_free (char *str);
+
+/* Allocate memory in GNU make's context. */
+char * GMK_EXPORT gmk_alloc (unsigned int len);
/* Run $(eval ...) on the provided string BUFFER. */
void GMK_EXPORT gmk_eval (const char *buffer, const gmk_floc *floc);
/* Run GNU make expansion on the provided string STR.
- Returns an allocated buffer that the caller must free. */
+ Returns an allocated buffer that the caller must free with gmk_free(). */
char * GMK_EXPORT gmk_expand (const char *str);
/* Register a new GNU make function NAME (maximum of 255 chars long).
@@ -50,7 +54,7 @@ char * GMK_EXPORT gmk_expand (const char *str);
The return value of FUNC must be either NULL, in which case it expands to
the empty string, or a pointer to the result of the expansion in a string
- created by malloc(). GNU make will free() the memory when it's done.
+ created by gmk_alloc(). GNU make will free the memory when it's done.
MIN_ARGS is the minimum number of arguments the function requires.
MAX_ARGS is the maximum number of arguments (or 0 if there's no maximum).
@@ -60,8 +64,8 @@ char * GMK_EXPORT gmk_expand (const char *str);
before FUNC is called. If EXPAND_ARGS is non-0, they will be expanded.
*/
void GMK_EXPORT gmk_add_function (const char *name,
- char *(*func)(const char *nm,
- int argc, char **argv),
- int min_args, int max_args, int expand_args);
+ char *(*func)(const char *nm,
+ int argc, char **argv),
+ int min_args, int max_args, int expand_args);
#endif /* _GNUMAKE_H_ */