sed: replace ck_realloc with gnulib's xrealloc/xnrealloc
* basicdefs.h (REALLOC): Call xnrealloc instead of ck_realloc. * sed/utils.c (ck_realloc): Remove.
This commit is contained in:
1 parent
e68a03d750
commit
cd549fb19a
2 files changed
+5
-24
No files matched your search
+1
-1
@@ -34,7 +34,7 @@ typedef unsigned long countT;
|
||||
#include "xalloc.h"
|
||||
|
||||
/* some basic definitions to avoid undue promulgating of ugliness */
|
||||
#define REALLOC(x,n,t) ((t *)ck_realloc((void *)(x),(n)*sizeof(t)))
|
||||
#define REALLOC(x,n,t) ((t *)xnrealloc((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)))
|
||||
|
||||
|
||||
+4
-23
@@ -319,8 +319,8 @@ follow_symlink(const char *fname)
|
||||
while ((rc = readlink (buf, buf2, buf_size)) == buf_size)
|
||||
{
|
||||
buf_size *= 2;
|
||||
buf1 = ck_realloc (buf1, buf_size);
|
||||
buf2 = ck_realloc (buf2, buf_size);
|
||||
buf1 = xrealloc (buf1, buf_size);
|
||||
buf2 = xrealloc (buf2, buf_size);
|
||||
}
|
||||
if (rc < 0)
|
||||
panic (_("couldn't follow symlink %s: %s"), buf, strerror(errno));
|
||||
@@ -335,8 +335,8 @@ follow_symlink(const char *fname)
|
||||
if (len + rc + 1 > buf_size)
|
||||
{
|
||||
buf_size = len + rc + 1;
|
||||
buf1 = ck_realloc (buf1, buf_size);
|
||||
buf2 = ck_realloc (buf2, buf_size);
|
||||
buf1 = xrealloc (buf1, buf_size);
|
||||
buf2 = xrealloc (buf2, buf_size);
|
||||
}
|
||||
|
||||
/* Always store the new path in buf1. */
|
||||
@@ -393,25 +393,6 @@ ck_rename (const char *from, const char *to, const char *unlink_if_fail)
|
||||
|
||||
|
||||
|
||||
/* Panic on failing realloc */
|
||||
void *
|
||||
ck_realloc(void *ptr, size_t size)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
if (!ptr)
|
||||
return xzalloc(size);
|
||||
ret = realloc(ptr, size);
|
||||
if (!ret)
|
||||
panic("couldn't re-allocate memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Implement a variable sized buffer of `stuff'. We don't know what it is,
|
||||
nor do we care, as long as it doesn't mind being aligned by malloc. */
|
||||
|
||||
Reference in new issue
Block a user