From: Chong Yidong Date: Mon, 20 Feb 2006 16:25:21 +0000 (+0000) Subject: * regex.c (xmalloc, xrealloc): Define these when not linked to X-Git-Tag: emacs-pretest-22.0.90~4002 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a77f947b23c1cc19f049b2d70b930f974bde6540;p=emacs.git * regex.c (xmalloc, xrealloc): Define these when not linked to Emacs. --- diff --git a/src/ChangeLog b/src/ChangeLog index f2a6e1e2752..1ed2e8512e2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2006-02-20 Chong Yidong + + * regex.c (xmalloc, xrealloc): Define these when not linked to + Emacs. + 2006-02-19 Luc Teirlinck * regex.c (extend_range_table_work_area): Fix typo. diff --git a/src/regex.c b/src/regex.c index c08471355fd..9cc6c8c08ee 100644 --- a/src/regex.c +++ b/src/regex.c @@ -181,6 +181,42 @@ char *malloc (); char *realloc (); # endif +/* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ + +void * +xmalloc (size) + size_t size; +{ + register void *val; + val = (void *) malloc (size); + if (!val && size) + { + write (2, "virtual memory exhausted\n", 25); + exit (1); + } + return val; +} + +void * +xrealloc (block, size) + void *block; + size_t size; +{ + register void *val; + /* We must call malloc explicitly when BLOCK is 0, since some + reallocs don't do this. */ + if (! block) + val = (void *) malloc (size); + else + val = (void *) realloc (block, size); + if (!val && size) + { + write (2, "virtual memory exhausted\n", 25); + exit (1); + } + return val; +} + /* When used in Emacs's lib-src, we need to get bzero and bcopy somehow. If nothing else has been done, use the method below. */ # ifdef INHIBIT_STRING_HEADER