mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-29 20:46:22 -05:00
uemacs: Add xmalloc as a wrapper function for malloc.
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>
This commit is contained in:
parent
bf3c3ac2bd
commit
6e4aec520e
6
window.c
6
window.c
@ -11,6 +11,7 @@
|
|||||||
#include "edef.h"
|
#include "edef.h"
|
||||||
#include "efunc.h"
|
#include "efunc.h"
|
||||||
#include "line.h"
|
#include "line.h"
|
||||||
|
#include "wrapper.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reposition dot in the current window to line "n". If the argument is
|
* Reposition dot in the current window to line "n". If the argument is
|
||||||
@ -323,10 +324,7 @@ int splitwind(int f, int n)
|
|||||||
mlwrite("Cannot split a %d line window", curwp->w_ntrows);
|
mlwrite("Cannot split a %d line window", curwp->w_ntrows);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if ((wp = (struct window *)malloc(sizeof(struct window))) == NULL) {
|
wp = xmalloc(sizeof(struct window));
|
||||||
mlwrite("(OUT OF MEMORY)");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
++curbp->b_nwnd; /* Displayed twice. */
|
++curbp->b_nwnd; /* Displayed twice. */
|
||||||
wp->w_bufp = curbp;
|
wp->w_bufp = curbp;
|
||||||
wp->w_dotp = curwp->w_dotp;
|
wp->w_dotp = curwp->w_dotp;
|
||||||
|
@ -12,3 +12,11 @@ int xmkstemp(char *template)
|
|||||||
die("Unable to create temporary file");
|
die("Unable to create temporary file");
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *xmalloc(size_t size)
|
||||||
|
{
|
||||||
|
void *ret = malloc(size);
|
||||||
|
if (!ret)
|
||||||
|
die("Out of memory");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user