From: Felix Fietkau Date: Tue, 3 Jun 2014 21:03:41 +0000 (+0200) Subject: dns: use bss instead of heap for buffers X-Git-Url: http://git.openwrt.org/?p=project%2Fmdnsd.git;a=commitdiff_plain;h=6585bb9209c56d1653c0527ed5b7de4a6279b7bb dns: use bss instead of heap for buffers Signed-off-by: Felix Fietkau --- diff --git a/dns.c b/dns.c index 75e739d..6389f8c 100644 --- a/dns.c +++ b/dns.c @@ -36,8 +36,8 @@ #include "util.h" #include "dns.h" -char *rdata_buffer; -static char *name_buffer; +char rdata_buffer[MAX_DATA_LEN + 1]; +static char name_buffer[MAX_NAME_LEN + 1]; const char* dns_type_string(uint16_t type) @@ -330,25 +330,3 @@ dns_consume_name(uint8_t *base, int blen, uint8_t **data, int *len) return name_buffer; } - -int -dns_init(void) -{ - name_buffer = malloc(MAX_NAME_LEN + 1); - rdata_buffer = malloc(MAX_DATA_LEN + 1); - - if (!name_buffer || !rdata_buffer) - return -1; - - memset(name_buffer, 0, MAX_NAME_LEN + 1); - memset(rdata_buffer, 0, MAX_NAME_LEN + 1); - - return 0; -} - -void -dns_cleanup(void) -{ - free(name_buffer); - free(rdata_buffer); -} diff --git a/dns.h b/dns.h index b29e297..4590123 100644 --- a/dns.h +++ b/dns.h @@ -64,10 +64,8 @@ struct dns_question { uint16_t class; } __attribute__((packed, aligned(2))); -extern char *rdata_buffer; +extern char rdata_buffer[MAX_DATA_LEN + 1]; -extern int dns_init(void); -extern void dns_cleanup(void); extern void dns_send_question(struct uloop_fd *u, char *question, int type); extern void dns_init_answer(void); extern void dns_add_answer(int type, uint8_t *rdata, uint16_t rdlength); diff --git a/main.c b/main.c index cc17903..39b8320 100644 --- a/main.c +++ b/main.c @@ -237,9 +237,6 @@ main(int argc, char **argv) fprintf(stderr, "interface %s has ip %s and index %d\n", iface_name, iface_ip, iface_index); signal_setup(); - if (dns_init()) - return -1; - if (cache_init()) return -1; @@ -254,7 +251,6 @@ main(int argc, char **argv) uloop_run(); uloop_done(); - dns_cleanup(); cache_cleanup(); service_cleanup();