[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix memory_error_and_abort()
From: |
Markus Elfring |
Subject: |
Fix memory_error_and_abort() |
Date: |
Tue, 18 Oct 2022 18:05:40 +0200 |
Hello,
I took another look at the implementation of the function
“memory_error_and_abort”.
A)
String literals are passed by two related functions while a pointer
to a mutable character array is expected as an input parameter so far.
Would you like to add a well-known key word here?
diff --git a/xmalloc.c b/xmalloc.c
index 5d01d75..266415c 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -42,3 +42,3 @@
static void
-memory_error_and_abort (char *fname)
+memory_error_and_abort (char const * const fname)
{
B)
The output of the error message can also fail after a memory allocation failure
was detected.
Would it be clearer to indicate ignorance of the corresponding return code
from a function call by a cast?
diff --git a/xmalloc.c b/xmalloc.c
index 5d01d75..7ba3f6f 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -46,4 +46,4 @@
{
- fprintf (stderr, "%s: out of virtual memory\n", fname);
+ (void) fprintf (stderr, "%s: out of virtual memory\n", fname);
exit (2);
}
Regards,
Markus
- Fix memory_error_and_abort(),
Markus Elfring <=