From d74fd3c72be778a1ff4663bf73443bae771d4ce1 Mon Sep 17 00:00:00 2001 From: Janne Blomqvist Date: Mon, 26 May 2014 23:56:45 +0300 Subject: Introduce xrealloc, use it. 2014-05-26 Janne Blomqvist * libgfortran.h (xrealloc): New prototype. * runtime/memory.c (xrealloc): New function. * io/fbuf.c (fbuf_alloc): Use xrealloc. * io/list_read.c (push_char_default): Likewise. (push_char4): Likewise. From-SVN: r210948 --- libgfortran/runtime/memory.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libgfortran/runtime') diff --git a/libgfortran/runtime/memory.c b/libgfortran/runtime/memory.c index efeea86f15a..b18b50532c7 100644 --- a/libgfortran/runtime/memory.c +++ b/libgfortran/runtime/memory.c @@ -58,3 +58,17 @@ xcalloc (size_t nmemb, size_t size) return p; } + + +void * +xrealloc (void *ptr, size_t size) +{ + if (size == 0) + size = 1; + + void *newp = realloc (ptr, size); + if (!newp) + os_error ("Memory allocation failure in xrealloc"); + + return newp; +} -- cgit v1.2.1