summaryrefslogtreecommitdiff
path: root/ncurses/tinfo/doalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'ncurses/tinfo/doalloc.c')
-rw-r--r--ncurses/tinfo/doalloc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ncurses/tinfo/doalloc.c b/ncurses/tinfo/doalloc.c
index f0c8141..e3b1a2e 100644
--- a/ncurses/tinfo/doalloc.c
+++ b/ncurses/tinfo/doalloc.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2021 Thomas E. Dickey *
* Copyright 1998-2002,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,15 +40,18 @@
#include <curses.priv.h>
-MODULE_ID("$Id: doalloc.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: doalloc.c,v 1.14 2021/04/24 23:43:39 tom Exp $")
-NCURSES_EXPORT(void *)
+void *
_nc_doalloc(void *oldp, size_t amount)
{
void *newp;
- if (oldp != 0) {
- if ((newp = realloc(oldp, amount)) == 0) {
+ if (oldp != NULL) {
+ if (amount == 0) {
+ free(oldp);
+ newp = NULL;
+ } else if ((newp = realloc(oldp, amount)) == 0) {
free(oldp);
errno = ENOMEM; /* just in case 'free' reset */
}