diff options
| author | 2022-10-07 09:46:23 +0200 | |
|---|---|---|
| committer | 2022-10-07 09:46:23 +0200 | |
| commit | a62e830ced0e3ee425e6f8be26624bdd5f504b73 (patch) | |
| tree | 056483a0aa38de382d6385be8935cebd68dbd739 | |
| parent | Updated TODO. (diff) | |
| download | penes-snac2-a62e830ced0e3ee425e6f8be26624bdd5f504b73.tar.gz penes-snac2-a62e830ced0e3ee425e6f8be26624bdd5f504b73.tar.xz penes-snac2-a62e830ced0e3ee425e6f8be26624bdd5f504b73.zip | |
abort() on realloc() error.
| -rw-r--r-- | xs.h | 14 |
1 files changed, 12 insertions, 2 deletions
| @@ -213,8 +213,18 @@ d_char *xs_expand(d_char *data, int offset, int size) | |||
| 213 | int n; | 213 | int n; |
| 214 | 214 | ||
| 215 | /* open room */ | 215 | /* open room */ |
| 216 | if (sz == 0 || _xs_blk_size(sz) != _xs_blk_size(sz + size)) | 216 | if (sz == 0 || _xs_blk_size(sz) != _xs_blk_size(sz + size)) { |
| 217 | data = realloc(data, _xs_blk_size(sz + size)); | 217 | d_char *ndata; |
| 218 | |||
| 219 | ndata = realloc(data, _xs_blk_size(sz + size)); | ||
| 220 | |||
| 221 | if (ndata == NULL) { | ||
| 222 | fprintf(stderr, "**OUT OF MEMORY**"); | ||
| 223 | abort(); | ||
| 224 | } | ||
| 225 | else | ||
| 226 | data = ndata; | ||
| 227 | } | ||
| 218 | 228 | ||
| 219 | /* move up the rest of the data */ | 229 | /* move up the rest of the data */ |
| 220 | for (n = sz + size - 1; n >= offset + size; n--) | 230 | for (n = sz + size - 1; n >= offset + size; n--) |