commit 637a2eeb66ff579f2a314af25bd2f3708cd87f2c
parent 13caef2de0cbd781a5dda3fbff74c42470af0c13
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 1 Feb 2022 11:55:31 +0100
tweaks: rename a variable and a parameter, to be more descriptive
Also, improve two comments, to describe what the functions actually do.
Diffstat:
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git 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.