mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 21:35:04 +00:00
abort() on realloc() error.
This commit is contained in:
parent
d2edc2aa9b
commit
a62e830ced
1 changed files with 12 additions and 2 deletions
14
xs.h
14
xs.h
|
@ -213,8 +213,18 @@ d_char *xs_expand(d_char *data, int offset, int size)
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
/* open room */
|
/* open room */
|
||||||
if (sz == 0 || _xs_blk_size(sz) != _xs_blk_size(sz + size))
|
if (sz == 0 || _xs_blk_size(sz) != _xs_blk_size(sz + size)) {
|
||||||
data = realloc(data, _xs_blk_size(sz + size));
|
d_char *ndata;
|
||||||
|
|
||||||
|
ndata = realloc(data, _xs_blk_size(sz + size));
|
||||||
|
|
||||||
|
if (ndata == NULL) {
|
||||||
|
fprintf(stderr, "**OUT OF MEMORY**");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
data = ndata;
|
||||||
|
}
|
||||||
|
|
||||||
/* move up the rest of the data */
|
/* move up the rest of the data */
|
||||||
for (n = sz + size - 1; n >= offset + size; n--)
|
for (n = sz + size - 1; n >= offset + size; n--)
|
||||||
|
|
Loading…
Reference in a new issue