diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2024-06-20 08:11:38 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2024-06-20 08:11:38 +0000 |
commit | 24fa7a5107c5b75d1c197accf0305be64bc72882 (patch) | |
tree | 183f09c93417ac0e5f7f49760329a3d2cfaacda9 /ncurses/tinfo/doalloc.c | |
parent | bf0ab54638a5ef969749f6ceae30e864f9556ea8 (diff) |
Diffstat (limited to 'ncurses/tinfo/doalloc.c')
-rw-r--r-- | ncurses/tinfo/doalloc.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ncurses/tinfo/doalloc.c b/ncurses/tinfo/doalloc.c index 0bda12cae8be..e3b1a2e96c1b 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.13 2020/08/30 00:27:15 tom Exp $") +MODULE_ID("$Id: doalloc.c,v 1.14 2021/04/24 23:43:39 tom Exp $") 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 */ } |