]> git.eshelyaron.com Git - emacs.git/commitdiff
* regex.c (xmalloc, xrealloc): Define these when not linked to
authorChong Yidong <cyd@stupidchicken.com>
Mon, 20 Feb 2006 16:25:21 +0000 (16:25 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Mon, 20 Feb 2006 16:25:21 +0000 (16:25 +0000)
Emacs.

src/ChangeLog
src/regex.c

index f2a6e1e2752177bfb8c1da953c4d4e6bb00df660..1ed2e8512e2f20ba3080a0bcb91aee2ad9484602 100644 (file)
@@ -1,3 +1,8 @@
+2006-02-20  Chong Yidong  <cyd@stupidchicken.com>
+
+       * regex.c (xmalloc, xrealloc): Define these when not linked to
+       Emacs.
+
 2006-02-19  Luc Teirlinck  <teirllm@auburn.edu>
 
        * regex.c (extend_range_table_work_area): Fix typo.
index c08471355fd3b3c2cd45a6bdb379aed7fcbc91bf..9cc6c8c08eec8a4e9a12a9fdee47fb28a5935465 100644 (file)
@@ -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