From f593b2198061d2d66faa2cda5d06535de0405c62 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Mon, 30 Jul 2018 23:36:35 -0600 Subject: [PATCH] sed: replace ck_memdup with gnulib's xmemdup * bootstrap.conf: Add gnulib's xalloc module. * basicdefs.h (MEMDUP): Remove. * sed/utils.{c,h} (ck_memdup): Remove. --- basicdefs.h | 4 +++- bootstrap.conf | 1 + sed/utils.c | 7 ------- sed/utils.h | 2 -- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/basicdefs.h b/basicdefs.h index bdbc45c..bf61826 100644 --- a/basicdefs.h +++ b/basicdefs.h @@ -31,10 +31,12 @@ /* type countT is used to keep track of line numbers, etc. */ typedef unsigned long countT; +#include "xalloc.h" + /* some basic definitions to avoid undue promulgating of ugliness */ #define MALLOC(n,t) ((t *)ck_malloc((n)*sizeof(t))) #define REALLOC(x,n,t) ((t *)ck_realloc((void *)(x),(n)*sizeof(t))) -#define MEMDUP(x,n,t) ((t *)ck_memdup((void *)(x),(n)*sizeof(t))) +#define MEMDUP(x,n,t) ((t *)xmemdup((x),(n)*sizeof(t))) #define OB_MALLOC(o,n,t) ((t *)(void *)obstack_alloc(o,(n)*sizeof(t))) #define obstack_chunk_alloc ck_malloc diff --git a/bootstrap.conf b/bootstrap.conf index 75c6654..5227ee2 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -64,6 +64,7 @@ verify version-etc-fsf wcrtomb wctob +xalloc ' gnulib_name=libsed diff --git a/sed/utils.c b/sed/utils.c index e9835d1..83d3015 100644 --- a/sed/utils.c +++ b/sed/utils.c @@ -429,13 +429,6 @@ ck_strdup(const char *str) return strcpy(ret, str); } -/* Return a malloc()'d copy of a block of memory */ -void * -ck_memdup(const void *buf, size_t len) -{ - void *ret = ck_malloc(len); - return memcpy(ret, buf, len); -} /* Implement a variable sized buffer of `stuff'. We don't know what it is, diff --git a/sed/utils.h b/sed/utils.h index e3727de..9fd09b4 100644 --- a/sed/utils.h +++ b/sed/utils.h @@ -43,10 +43,8 @@ FILE * ck_mkstemp (char **p_filename, const char *tmpdir, const char *base, void ck_rename (const char *from, const char *to, const char *unlink_if_fail); void *ck_malloc (size_t size); -void *xmalloc (size_t size); void *ck_realloc (void *ptr, size_t size); char *ck_strdup (const char *str); -void *ck_memdup (const void *buf, size_t len); struct buffer *init_buffer (void); char *get_buffer (struct buffer const *b) _GL_ATTRIBUTE_PURE;