diff options
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | lib/Makefile.am | 4 | ||||
-rw-r--r-- | lib/lib.c | 7 | ||||
-rwxr-xr-x | lib/malloc.c | 17 | ||||
-rw-r--r-- | lib/realloc.c | 27 |
6 files changed, 61 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index cf28658..a354699 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,6 +66,9 @@ flex_SOURCES = \ filter.c \ regex.c + +LDADD = lib/libcompat.a + libfl_a_SOURCES = \ libmain.c \ libyywrap.c @@ -113,6 +116,7 @@ BUILT_SOURCES = \ skel.c SUBDIRS = \ + lib \ . \ doc \ examples \ diff --git a/configure.in b/configure.in index cbbb754..1563137 100644 --- a/configure.in +++ b/configure.in @@ -29,6 +29,7 @@ AC_INIT([the fast lexical analyser generator], [2.5.36], AC_CONFIG_SRCDIR([scan.l]) AM_INIT_AUTOMAKE([gnits dist-bzip2 1.10]) AC_CONFIG_HEADER([config.h:conf.in]) +AC_CONFIG_LIBOBJ_DIR([lib]) # checks for programs @@ -112,6 +113,7 @@ doc/Makefile examples/Makefile examples/fastwc/Makefile examples/manual/Makefile +lib/Makefile po/Makefile.in tools/Makefile tests/Makefile diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 0000000..53b4d48 --- /dev/null +++ b/lib/Makefile.am @@ -0,0 +1,4 @@ +noinst_LIBRARIES = libcompat.a +libcompat_a_SOURCES = lib.c +libcompat_a_LIBADD = $(LIBOBJS) + diff --git a/lib/lib.c b/lib/lib.c new file mode 100644 index 0000000..a8ff70f --- /dev/null +++ b/lib/lib.c @@ -0,0 +1,7 @@ +/* Since building an empty library could cause problems, we provide a + * function to go into the library. We could make this non-trivial by + * moving something that flex treats as a library function into this + * directory. */ + +void do_nothing(){ return;} + diff --git a/lib/malloc.c b/lib/malloc.c new file mode 100755 index 0000000..d4c605f --- /dev/null +++ b/lib/malloc.c @@ -0,0 +1,17 @@ + #include <config.h>
+ #undef malloc
+
+ #include <sys/types.h>
+
+ void *malloc ();
+
+ /* Allocate an N-byte block of memory from the heap.
+ If N is zero, allocate a 1-byte block. */
+
+ void *
+ rpl_malloc (size_t n)
+ {
+ if (n == 0)
+ n = 1;
+ return malloc (n);
+ }
diff --git a/lib/realloc.c b/lib/realloc.c new file mode 100644 index 0000000..d7bb629 --- /dev/null +++ b/lib/realloc.c @@ -0,0 +1,27 @@ +#include <config.h> + +#include <stdlib.h> + +#include <errno.h> + +void * rpl_realloc (void *p, size_t n) +{ + void *result; + + if (n == 0) + { + n = 1; + } + + if (p == NULL) + { + result = malloc (n); + } + else + result = realloc (p, n); + + if (result == NULL) + errno = ENOMEM; + + return result; +} |