reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here.
Many files:
reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here.
bk: 55d58c90JEJab5Wrv2_PWdzL1J3M8A
goto err;
len = strlen(decoded_path)+strlen(docroot)+2;
- if (!(whole_path = emalloc(len))) {
+ if (!(whole_path = malloc(len))) {
perror("malloc");
goto err;
}
#ifdef _WIN32
dirlen = strlen(whole_path);
- pattern = emalloc(dirlen+3);
+ pattern = malloc(dirlen+3);
+ if (!pattern) {
+ perror("malloc");
+ goto err;
+ }
memcpy(pattern, whole_path, dirlen);
pattern[dirlen] = '\\';
pattern[dirlen+1] = '*';
}
}
- ri = emalloc(sizeof(*ri));
+ ri = malloc(sizeof(*ri));
+ if (ri == NULL) {
+ printf("Unable to allocate memory in launch_request()\n");
+ return -1;
+ }
ri->n_read = 0;
evutil_gettimeofday(&ri->started, NULL);
static void *
dummy_malloc(size_t len)
{
- char *mem = emalloc(len+16);
+ char *mem = malloc(len+16);
+ if (mem == NULL) {
+ fprintf(stderr, "Unable to allocate memory in dummy_malloc()\n");
+ return NULL;
+ }
memcpy(mem, "{[<guardedram>]}", 16);
return mem+16;
}
return dummy_malloc(len);
tt_want(check_dummy_mem_ok(mem_));
mem -= 16;
- mem = erealloc(mem, len+16);
+ mem = realloc(mem, len+16);
return mem+16;
}
int n_dns_questions = 0;
struct evdns_base *dns_base;
- memset(a_out, 0, sizeof(a_out));
+ memset(&a_out, 0, sizeof(a_out));
memset(&local_outcome, 0, sizeof(local_outcome));
dns_base = evdns_base_new(data->base, 0);
static void
gaic_launch(struct event_base *base, struct evdns_base *dns_base)
{
- struct gaic_request_status *status = emalloc_zero(1 * sizeof(*status)); //calloc
+ struct gaic_request_status *status = calloc(1, sizeof(*status));
+ tt_assert(status);
struct timeval tv = { 0, 10000 };
status->magic = GAIC_MAGIC;
status->base = base;
cnt_malloc(size_t sz)
{
allocated_chunks += 1;
- return emalloc(sz);
+ return malloc(sz);
}
static void *
allocated_chunks += 1;
if (!sz)
allocated_chunks -= 1;
- return erealloc(old, sz);
+ return realloc(old, sz);
}
static void
event_enable_debug_mode();
/* not mm_calloc: we don't want to mess with the count. */
- env = emalloc_zero(1 * sizeof(struct testleak_env_t)); //calloc
+ env = calloc(1, sizeof(struct testleak_env_t));
env->base = event_base_new();
env->dns_base = evdns_base_new(env->base, 0);
env->req = evdns_base_resolve_ipv4(
http_chunked_cb(struct evhttp_request *req, void *arg)
{
struct timeval when = { 0, 0 };
- struct chunk_req_state *state = emalloc(sizeof(struct chunk_req_state));
+ struct chunk_req_state *state = malloc(sizeof(struct chunk_req_state));
event_debug(("%s: called\n", __func__));
+ if (state == NULL) {
+ fprintf(stderr, "Unable to allocate memory in http_chunked_cb()\n");
+ exit(1);
+ }
memset(state, 0, sizeof(struct chunk_req_state));
state->req = req;
buf[n]='\0';
if (*output)
free(*output);
- *output = estrdup(buf);
+ *output = strdup(buf);
}
event_base_loopexit(exit_base, NULL);
}
s = NULL;
/* Now try decoding just part of string. */
- s = emalloc(6 + 1 /* NUL byte */);
+ s = malloc(6 + 1 /* NUL byte */);
bytes_decoded = evhttp_decode_uri_internal("hello%20%20", 6, s, 0);
tt_assert(s);
tt_int_op(bytes_decoded,==,6);
min_heap_ctor_(&heap);
for (i = 0; i < 1024; ++i) {
- inserted[i] = emalloc(sizeof(struct event));
+ inserted[i] = malloc(sizeof(struct event));
+ assert(inserted[i] != NULL);
set_random_timeout(inserted[i]);
min_heap_push_(&heap, inserted[i]);
}
if (expected_total_persec > 0)
expected_total_persec /= seconds_per_tick;
- bevs = emalloc_zero(cfg_n_connections * sizeof(struct bufferevent *)); //calloc
- states = emalloc_zero(cfg_n_connections * sizeof(struct client_state)); //calloc
+ bevs = calloc(cfg_n_connections, sizeof(struct bufferevent *));
+ states = calloc(cfg_n_connections, sizeof(struct client_state));
+ if (bevs == NULL || states == NULL) {
+ printf("Unable to allocate memory...\n");
+ return 1;
+ }
for (i = 0; i < cfg_n_connections; ++i) {
bevs[i] = bufferevent_socket_new(base, -1,
event_init();
for (i = 0; i < NEVENT; i++) {
- ev[i] = emalloc(sizeof(struct event));
+ ev[i] = malloc(sizeof(struct event));
+ assert(ev[i] != NULL);
/* Initalize one event */
evtimer_set(ev[i], time_cb, ev[i]);