Commit 65f8455d authored by Daniel Salzman's avatar Daniel Salzman

libknot: remove KNOT_ERR_ALLOC_FAILED

parent 9ed03e72
......@@ -412,7 +412,6 @@ static int conf_process(conf_t *conf)
size_t size = stor_len + zname_len + 9; // /diff.db,\0
char *dest = malloc(size);
if (dest == NULL) {
KNOT_ERR_ALLOC_FAILED;
zone->ixfr_db = NULL; /* Not enough memory. */
ret = KNOT_ENOMEM; /* Error report. */
continue;
......
......@@ -200,7 +200,6 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
size_t path_len = strlen(keydir_name) + 1 + strlen(entry->d_name);
char *path = malloc((path_len + 1) * sizeof(char));
if (!path) {
KNOT_ERR_ALLOC_FAILED;
closedir(keydir);
return KNOT_ENOMEM;
}
......
......@@ -996,7 +996,6 @@ static int add_rr_type_to_list(const knot_rrset_t *rr, list_t *l)
type_node_t *n = malloc(sizeof(type_node_t));
if (n == NULL) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
n->type = rr->type;
......@@ -1031,7 +1030,6 @@ static int rr_already_signed(const knot_rrset_t *rrset, hattrie_t *t,
// Create new info struct
signed_info_t *info = malloc(sizeof(signed_info_t));
if (info == NULL) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
memset(info, 0, sizeof(signed_info_t));
......@@ -1044,7 +1042,6 @@ static int rr_already_signed(const knot_rrset_t *rrset, hattrie_t *t,
// Create new list to insert as a value
info->type_list = malloc(sizeof(list_t));
if (info->type_list == NULL) {
KNOT_ERR_ALLOC_FAILED;
free(info->dname);
free(info);
return KNOT_ENOMEM;
......
......@@ -152,7 +152,6 @@ changeset_t *changeset_new(const knot_dname_t *apex)
{
changeset_t *ret = malloc(sizeof(changeset_t));
if (ret == NULL) {
KNOT_ERR_ALLOC_FAILED;
return NULL;
}
......
......@@ -153,7 +153,6 @@ static int discover_additionals(struct rr_data *rr_data,
}
rr_data->additional = malloc(rdcount * sizeof(zone_node_t *));
if (rr_data->additional == NULL) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
......@@ -1255,7 +1254,6 @@ int zone_contents_shallow_copy(const zone_contents_t *from, zone_contents_t **to
zone_contents_t *contents = calloc(1, sizeof(zone_contents_t));
if (contents == NULL) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
......
......@@ -88,7 +88,6 @@ zone_node_t *node_new(const knot_dname_t *owner, mm_ctx_t *mm)
{
zone_node_t *ret = mm_alloc(mm, sizeof(zone_node_t));
if (ret == NULL) {
KNOT_ERR_ALLOC_FAILED;
return NULL;
}
memset(ret, 0, sizeof(*ret));
......
......@@ -530,7 +530,6 @@ static int rdata_nsec_to_type_array(const knot_rdataset_t *rrs, uint16_t type,
uint8_t *bitmap =
malloc(sizeof(uint8_t) * (bitmap_size));
if (bitmap == NULL) {
KNOT_ERR_ALLOC_FAILED;
free(*array);
return KNOT_ENOMEM;
}
......@@ -547,7 +546,6 @@ static int rdata_nsec_to_type_array(const knot_rdataset_t *rrs, uint16_t type,
sizeof(uint16_t) *
*count);
if (tmp == NULL) {
KNOT_ERR_ALLOC_FAILED;
free(bitmap);
free(*array);
return KNOT_ENOMEM;
......
......@@ -138,7 +138,6 @@ int zone_dump_text(zone_contents_t *zone, const struct sockaddr_storage *from, F
// Allocate auxiliary buffer for dumping operations.
char *buf = malloc(DUMP_BUF_LEN);
if (buf == NULL) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
......
......@@ -56,7 +56,6 @@ zone_t* zone_new(conf_zone_t *conf)
zone_t *zone = malloc(sizeof(zone_t));
if (zone == NULL) {
KNOT_ERR_ALLOC_FAILED;
return NULL;
}
memset(zone, 0, sizeof(zone_t));
......@@ -65,7 +64,6 @@ zone_t* zone_new(conf_zone_t *conf)
knot_dname_to_lower(zone->name);
if (zone->name == NULL) {
free(zone);
KNOT_ERR_ALLOC_FAILED;
return NULL;
}
......
......@@ -217,7 +217,6 @@ int zonefile_open(zloader_t *loader, const char *source, const char *origin,
/* Create context. */
zcreator_t *zc = malloc(sizeof(zcreator_t));
if (zc == NULL) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
memset(zc, 0, sizeof(zcreator_t));
......
......@@ -28,9 +28,6 @@
#pragma once
#define KNOT_NAME "lib" PACKAGE_NAME // Project name
#define KNOT_VER PACKAGE_VERSION // 0xMMIIRR (MAJOR,MINOR,REVISION)
#define _public_ __attribute__((visibility("default")))
#define _hidden_ __attribute__((visibility("hidden")))
......@@ -57,11 +54,4 @@
#define knot_unlikely(x) __builtin_expect((x),0)
#endif
/*! \todo Refactor theese. We should have an allocator function handling this.*/
#ifndef KNOT_ERR_ALLOC_FAILED
#define KNOT_ERR_ALLOC_FAILED fprintf(stderr, \
"Allocation failed at %s:%d (%s ver.%s)\n", \
__FILE__, __LINE__, KNOT_NAME, KNOT_VER)
#endif
/*! @} */
......@@ -70,7 +70,6 @@ static int add_rr_at(knot_rdataset_t *rrs, const knot_rdata_t *rr, size_t pos,
if (tmp) {
rrs->data = tmp;
} else {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
......@@ -125,7 +124,6 @@ static int remove_rr_at(knot_rdataset_t *rrs, size_t pos, mm_ctx_t *mm)
total_size - (knot_rdata_array_size(old_size)),
total_size);
if (tmp == NULL) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
} else {
rrs->data = tmp;
......@@ -169,7 +167,6 @@ int knot_rdataset_copy(knot_rdataset_t *dst, const knot_rdataset_t *src, mm_ctx_
size_t src_size = knot_rdataset_size(src);
dst->data = mm_alloc(mm, src_size);
if (dst->data == NULL) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
......
......@@ -39,7 +39,6 @@ knot_rrset_t *knot_rrset_new(const knot_dname_t *owner, uint16_t type,
knot_rrset_t *ret = mm_alloc(mm, sizeof(knot_rrset_t));
if (ret == NULL) {
KNOT_ERR_ALLOC_FAILED;
knot_dname_free(&owner_cpy, mm);
return NULL;
}
......
......@@ -318,7 +318,6 @@ static int create_sign_wire(const uint8_t *msg, size_t msg_len,
knot_tsig_rdata_tsig_variables_length(tmp_tsig));
uint8_t *wire = malloc(wire_len);
if (!wire) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
......@@ -392,7 +391,6 @@ static int create_sign_wire_next(const uint8_t *msg, size_t msg_len,
knot_tsig_rdata_tsig_timers_length() + 2);
uint8_t *wire = malloc(wire_len);
if (!wire) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
......@@ -563,7 +561,6 @@ int knot_tsig_sign_next(uint8_t *msg, size_t *msg_len, size_t msg_max_len,
+ KNOT_TSIG_TIMERS_LENGTH + 2;
uint8_t *wire = malloc(wire_len);
if (!wire) {
KNOT_ERR_ALLOC_FAILED;
knot_rrset_free(&tmp_tsig, NULL);
return KNOT_ENOMEM;
}
......@@ -679,7 +676,6 @@ static int check_digest(const knot_rrset_t *tsig_rr,
uint8_t *wire_to_sign = malloc(sizeof(uint8_t) * size);
if (!wire_to_sign) {
KNOT_ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment