From 637a2eeb66ff579f2a314af25bd2f3708cd87f2c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 1 Feb 2022 11:55:31 +0100 Subject: [PATCH] tweaks: rename a variable and a parameter, to be more descriptive Also, improve two comments, to describe what the functions actually do. --- src/utils.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/utils.c b/src/utils.c index f7fb95a1..8bcd2bda 100644 --- a/src/utils.c +++ b/src/utils.c @@ -282,28 +282,26 @@ const char *strstrwrapper(const char *haystack, const char *needle, return mbstrcasestr(start, needle); } -/* This is a wrapper for the malloc() function that properly handles - * things when we run out of memory. */ +/* Allocate the given amount of memory and return a pointer to it. */ void *nmalloc(size_t howmuch) { - void *r = malloc(howmuch); + void *section = malloc(howmuch); - if (r == NULL) + if (section == NULL) die(_("Nano is out of memory!\n")); - return r; + return section; } -/* This is a wrapper for the realloc() function that properly handles - * things when we run out of memory. */ -void *nrealloc(void *ptr, size_t howmuch) +/* Reallocate the given section of memory to have the given size. */ +void *nrealloc(void *section, size_t howmuch) { - void *r = realloc(ptr, howmuch); + section = realloc(section, howmuch); - if (r == NULL) + if (section == NULL) die(_("Nano is out of memory!\n")); - return r; + return section; } /* Return an appropriately reallocated dest string holding a copy of src.