mirror of
https://github.com/rfivet/uemacs.git
synced 2024-06-26 11:45:28 +00:00
xmalloc checks the returned pointer and dies if it failed to allocate the memory. Use this new function in window.c. More places will be converted to use xmalloc latter. Signed-off-by: Thiago Farina <tfransosi@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
23 lines
313 B
C
23 lines
313 B
C
#include "usage.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
/* Function copyright: git */
|
|
int xmkstemp(char *template)
|
|
{
|
|
int fd;
|
|
|
|
fd = mkstemp(template);
|
|
if (fd < 0)
|
|
die("Unable to create temporary file");
|
|
return fd;
|
|
}
|
|
|
|
void *xmalloc(size_t size)
|
|
{
|
|
void *ret = malloc(size);
|
|
if (!ret)
|
|
die("Out of memory");
|
|
return ret;
|
|
}
|