[Top][All Lists]
[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
- [PATCH 00/16] my last hefty patch drop, Paolo Bonzini, 2010/03/12
- [PATCH 01/17] kwset/system: remove ptr_t, Paolo Bonzini, 2010/03/12
- [PATCH 02/17] grep: cleanup one const cast, Paolo Bonzini, 2010/03/12
- [PATCH 03/17] dfa: get rid of x*alloc,
Paolo Bonzini <=
- [PATCH 04/17] dfa: remove CRANGE dead code, Paolo Bonzini, 2010/03/12
- [PATCH 05/17] dfa, grep: cleanup if-before-free and cast-of-argument-to-free, Paolo Bonzini, 2010/03/12
- [PATCH 07/17] syntax-check: enable makefile-TAB-only-indentation, Paolo Bonzini, 2010/03/12
- [PATCH 06/17] grep: fix error-message-uppercase, Paolo Bonzini, 2010/03/12