Return void pointer from xmalloc

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.
This commit is contained in:
Christian Göttsche 2022-08-05 17:40:28 +02:00 committed by Serge Hallyn
parent e32b4a9a81
commit c5090d91a1
2 changed files with 4 additions and 4 deletions

View 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);

View File

@ -26,11 +26,11 @@
#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"),