bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 03/17] dfa: get rid of x*alloc


From: Paolo Bonzini
Subject: [PATCH 03/17] dfa: get rid of x*alloc
Date: Fri, 12 Mar 2010 18:49:04 +0100

* src/dfa.c: Include xalloc.h.
(xmalloc, xrealloc, xcalloc): Remove.
---
 src/dfa.c |   35 ++---------------------------------
 src/dfa.h |   12 ------------
 2 files changed, 2 insertions(+), 45 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index d4663e3..aef789e 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -89,6 +89,7 @@
 #include "regex.h"
 #include "dfa.h"
 #include "hard-locale.h"
+#include "xalloc.h"
 
 /* HPUX, define those as macros in sys/param.h */
 #ifdef setbit
@@ -101,41 +102,9 @@
 static void dfamust (struct dfa *dfa);
 static void regexp (int toplevel);
 
-static ptr_t
-xcalloc (size_t n, size_t s)
-{
-  ptr_t r = calloc(n, s);
-
-  if (!r)
-    dfaerror(_("Memory exhausted"));
-  return r;
-}
-
-static ptr_t
-xmalloc (size_t n)
-{
-  ptr_t r = malloc(n);
-
-  assert(n != 0);
-  if (!r)
-    dfaerror(_("Memory exhausted"));
-  return r;
-}
-
-static ptr_t
-xrealloc (ptr_t p, size_t n)
-{
-  ptr_t r = realloc(p, n);
-
-  assert(n != 0);
-  if (!r)
-    dfaerror(_("Memory exhausted"));
-  return r;
-}
-
 #define CALLOC(p, t, n) ((p) = xcalloc((size_t)(n), sizeof (t)))
 #define MALLOC(p, t, n) ((p) = xmalloc((n) * sizeof (t)))
-#define REALLOC(p, t, n) ((p) = xrealloc((ptr_t) (p), (n) * sizeof (t)))
+#define REALLOC(p, t, n) ((p) = xrealloc((p), (n) * sizeof (t)))
 
 /* Reallocate an array of type t if nalloc is too small for index. */
 #define REALLOC_IF_NECESSARY(p, t, nalloc, index) \
diff --git a/src/dfa.h b/src/dfa.h
index f13a257..cff2b0b 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -23,18 +23,6 @@
    In addition to clobbering modularity, we eat up valuable
    name space. */
 
-#ifdef __STDC__
-# ifndef _PTR_T
-# define _PTR_T
-  typedef void * ptr_t;
-# endif
-#else
-# ifndef _PTR_T
-# define _PTR_T
-  typedef char * ptr_t;
-# endif
-#endif
-
 /* Number of bits in an unsigned char. */
 #ifndef CHARBITS
 #define CHARBITS 8
-- 
1.6.6






reply via email to

[Prev in Thread] Current Thread [Next in Thread]