Unified · Split
| @@ -237,6 +237,8 @@ PUB_FUNC void *tcc_realloc(void *ptr, unsigned long size) · 236 unmodified lines | ||
| 237 | 237 | mem_cur_size -= malloc_usable_size(ptr); |
| 238 | 238 | #endif |
| 239 | 239 | ptr1 = realloc(ptr, size); |
| 240 | + if (!ptr1 && size) | |
| 241 | + tcc_error("memory full"); | |
| 240 | 242 | #ifdef MEM_DEBUG |
| 241 | 243 | /* NOTE: count not correct if alloc error, but not critical */ |
| 242 | 244 | mem_cur_size += malloc_usable_size(ptr1); |
| @@ -282,8 +284,6 @@ PUB_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data) · 39 unmodified lines | ||
| 282 | 284 | else |
| 283 | 285 | nb_alloc = nb * 2; |
| 284 | 286 | pp = tcc_realloc(pp, nb_alloc * sizeof(void *)); |
| 285 | − if (!pp) | |
| 286 | − tcc_error("memory full"); | |
| 287 | 287 | *ptab = pp; |
| 288 | 288 | } |
| 289 | 289 | pp[nb++] = data; |
| @@ -377,8 +377,6 @@ ST_FUNC void section_realloc(Section *sec, unsigned long new_size) · 87 unmodified lines | ||
| 377 | 377 | while (size < new_size) |
| 378 | 378 | size = size * 2; |
| 379 | 379 | data = tcc_realloc(sec->data, size); |
| 380 | − if (!data) | |
| 381 | − tcc_error("memory full"); | |
| 382 | 380 | memset(data + sec->data_allocated, 0, size - sec->data_allocated); |
| 383 | 381 | sec->data = data; |
| 384 | 382 | sec->data_allocated = size; |
| @@ -836,8 +836,6 @@ static void put_got_offset(TCCState *s1, int index, unsigned long val) · 835 unmodified lines | ||
| 836 | 836 | while (index >= n) |
| 837 | 837 | n *= 2; |
| 838 | 838 | tab = tcc_realloc(s1->got_offsets, n * sizeof(unsigned long)); |
| 839 | − if (!tab) | |
| 840 | − tcc_error("memory full"); | |
| 841 | 839 | s1->got_offsets = tab; |
| 842 | 840 | memset(s1->got_offsets + s1->nb_got_offsets, 0, |
| 843 | 841 | (n - s1->nb_got_offsets) * sizeof(unsigned long)); |
| @@ -112,8 +112,6 @@ static void cstr_realloc(CString *cstr, int new_size) · 111 unmodified lines | ||
| 112 | 112 | while (size < new_size) |
| 113 | 113 | size = size * 2; |
| 114 | 114 | data = tcc_realloc(cstr->data_allocated, size); |
| 115 | − if (!data) | |
| 116 | − tcc_error("memory full"); | |
| 117 | 115 | cstr->data_allocated = data; |
| 118 | 116 | cstr->size_allocated = size; |
| 119 | 117 | cstr->data = data; |
| @@ -200,8 +198,6 @@ static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len) · 80 unmodified lines | ||
| 200 | 198 | i = tok_ident - TOK_IDENT; |
| 201 | 199 | if ((i % TOK_ALLOC_INCR) == 0) { |
| 202 | 200 | ptable = tcc_realloc(table_ident, (i + TOK_ALLOC_INCR) * sizeof(TokenSym *)); |
| 203 | − if (!ptable) | |
| 204 | − tcc_error("memory full"); | |
| 205 | 201 | table_ident = ptable; |
| 206 | 202 | } |
| 207 | 203 | |
| @@ -844,8 +840,6 @@ static int *tok_str_realloc(TokenString *s) · 636 unmodified lines | ||
| 844 | 840 | len = s->allocated_len * 2; |
| 845 | 841 | } |
| 846 | 842 | str = tcc_realloc(s->str, len * sizeof(int)); |
| 847 | − if (!str) | |
| 848 | − tcc_error("memory full"); | |
| 849 | 843 | s->allocated_len = len; |
| 850 | 844 | s->str = str; |
| 851 | 845 | return str; |