]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Return void pointer from xmalloc
authorChristian Göttsche <cgzones@googlemail.com>
Fri, 5 Aug 2022 15:40:28 +0000 (17:40 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sat, 6 Aug 2022 16:27:56 +0000 (11:27 -0500)
xmalloc is a wrapper around malloc(3), which bails out on OOM failures.
As such it returns raw memory and is used to allocated all kind of
types.

lib/prototypes.h
libmisc/xmalloc.c

index 4e997e32f01e0a9623e5569d9f6fb3fe5acd66e2..bd832f49125f95f3883b65bf3329083f4cbb3cb2 100644 (file)
@@ -480,7 +480,7 @@ extern int setutmpx (struct utmpx *utx);
 extern bool valid (const char *, const struct passwd *);
 
 /* xmalloc.c */
-extern /*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/char *xmalloc (size_t size)
+extern /*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/void *xmalloc (size_t size)
   /*@ensures MaxSet(result) == (size - 1); @*/;
 extern /*@maynotreturn@*/ /*@only@*//*@notnull@*/char *xstrdup (const char *);
 extern void xfree(void *ap);
index 9329e67444658fb88c6c96e815ee7c88607ab515..25b136a494d606efdb5844a138aec052f4ce45e8 100644 (file)
 #include "prototypes.h"
 #include "shadowlog.h"
 
-/*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/char *xmalloc (size_t size)
+/*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/void *xmalloc (size_t size)
 {
-       char *ptr;
+       void *ptr;
 
-       ptr = (char *) malloc (size);
+       ptr = malloc (size);
        if (NULL == ptr) {
                (void) fprintf (log_get_logfd(),
                                _("%s: failed to allocate memory: %s\n"),