Tweak method sigs

This commit is contained in:
Neel Goyal 2013-08-15 12:42:35 -04:00
parent 6c1dc93edf
commit 0c5d8b2c32
3 changed files with 16 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*~ *~
.DS_Store
Makefile.in Makefile.in
getdns*.tar.gz getdns*.tar.gz
*.o *.o

View File

@ -35,11 +35,11 @@
#define gd_malloc(sz) context->memory_allocator(sz) #define gd_malloc(sz) context->memory_allocator(sz)
#define gd_free(ptr) context->memory_deallocator(ptr) #define gd_free(ptr) context->memory_deallocator(ptr)
void network_req_free(getdns_context_t context, void network_req_free(getdns_network_req* net_req) {
getdns_network_req* net_req) {
if (!net_req) { if (!net_req) {
return; return;
} }
getdns_context_t context = net_req->context;
if (net_req->pkt) { if (net_req->pkt) {
ldns_pkt_free(net_req->pkt); ldns_pkt_free(net_req->pkt);
} }
@ -66,7 +66,7 @@ getdns_network_req* network_req_new(getdns_context_t context,
pkt = create_new_pkt(context, name, request_type, extensions); pkt = create_new_pkt(context, name, request_type, extensions);
if (!pkt) { if (!pkt) {
/* free up the req */ /* free up the req */
network_req_free(context, net_req); network_req_free(net_req);
return NULL; return NULL;
} }
net_req->pkt = pkt; net_req->pkt = pkt;
@ -78,12 +78,12 @@ getdns_network_req* network_req_new(getdns_context_t context,
return net_req; return net_req;
} }
void dns_req_free(getdns_context_t context, void dns_req_free(getdns_dns_req* req) {
getdns_dns_req* req) {
if (!req) { if (!req) {
return; return;
} }
network_req_free(context, req->current_req); getdns_context_t context = req->context;
network_req_free(req->current_req);
gd_free(req); gd_free(req);
} }
@ -108,7 +108,7 @@ getdns_dns_req* dns_req_new(getdns_context_t context,
net_req = network_req_new(context, name, request_type, net_req = network_req_new(context, name, request_type,
extensions, transaction_id); extensions, transaction_id);
if (!net_req) { if (!net_req) {
dns_req_free(context, result); dns_req_free(result);
result = NULL; result = NULL;
} }

View File

@ -65,7 +65,7 @@ typedef struct getdns_nameserver {
int requests_inflight; int requests_inflight;
} getdns_nameserver; } getdns_nameserver;
/* network request - state for a network request and referenced /* network request - state for a single network request and referenced
* by the the outbound_req * by the the outbound_req
*/ */
typedef struct getdns_network_req { typedef struct getdns_network_req {
@ -114,7 +114,7 @@ typedef struct getdns_dns_req {
/* utility methods */ /* utility methods */
/* network request utilities */ /* network request utilities */
void network_req_free(getdns_context_t context, getdns_network_req* net_req); void network_req_free(getdns_network_req* net_req);
getdns_network_req* network_req_new(getdns_context_t context, getdns_network_req* network_req_new(getdns_context_t context,
const char* name, const char* name,
@ -131,8 +131,12 @@ getdns_dns_req* dns_req_new(getdns_context_t context,
getdns_transaction_t *transaction_id); getdns_transaction_t *transaction_id);
void dns_req_free(getdns_context_t context, void dns_req_free(getdns_dns_req* req);
getdns_dns_req* req);
/* nameserver utils */
getdns_nameserver* nameserver_new_from_ip_dict(getdns_dict* ip_dict);
void nameserver_free(getdns_nameserver* nameserver);
#endif #endif