src/allocator.c

changeset 1040
1ecf4dbbc60c
parent 985
68754c7de906
equal deleted inserted replaced
1039:ec62453fc8a6 1040:1ecf4dbbc60c
97 size_t nmemb, 97 size_t nmemb,
98 size_t size 98 size_t size
99 ) { 99 ) {
100 size_t n; 100 size_t n;
101 if (cx_szmul(nmemb, size, &n)) { 101 if (cx_szmul(nmemb, size, &n)) {
102 errno = ENOMEM; 102 errno = EOVERFLOW;
103 return 1; 103 return 1;
104 } else { 104 } else {
105 void *nmem = realloc(*mem, n); 105 void *nmem = realloc(*mem, n);
106 if (nmem == NULL) { 106 if (nmem == NULL) {
107 return 1; 107 return 1;
135 size_t nmemb, 135 size_t nmemb,
136 size_t size 136 size_t size
137 ) { 137 ) {
138 size_t n; 138 size_t n;
139 if (cx_szmul(nmemb, size, &n)) { 139 if (cx_szmul(nmemb, size, &n)) {
140 errno = ENOMEM; 140 errno = EOVERFLOW;
141 return NULL; 141 return NULL;
142 } else { 142 } else {
143 return allocator->cl->realloc(allocator->data, mem, n); 143 return allocator->cl->realloc(allocator->data, mem, n);
144 } 144 }
145 } 145 }

mercurial