#INSTALL_PROGRAM = $(INSTALL)
LIBDNS_SOURCES=rdata.c util.c rr.c packet.c
-LIBDNS_HEADERS=rdata.h prototype.h rr.h packet.h
+LIBDNS_HEADERS=rdata.h prototype.h rr.h packet.h util.h
LIBDNS_OBJECTS=$(LIBDNS_SOURCES:.c=.o)
ALL_SOURCES=run-test0.c $(LIBDNS_SOURCES)
#include "rr.h"
#include "prototype.h"
#include "packet.h"
+#include "util.h"
/* Access functions
* do this as functions to get type checking
dns_packet_new()
{
t_packet *packet;
- packet = xmalloc(sizeof(t_packet));
+ MALLOC(packet, t_packet);
if (!packet)
return NULL;
- packet->header = xmalloc(sizeof(t_header));
+ MALLOC(packet_header, t_header);
if (!packet->header)
return NULL;
#else
#define _PROTOTYPE_H
-/* util.c */
-void *xmalloc(size_t);
-void *xrealloc(void *, size_t);
-void xprintf_rd_field(t_rdata_field *);
-void xprintf_rr(t_rr *);
+/* empty for now */
#endif /* _PROTOTYPE_H */
#include "rdata.h"
#include "rr.h"
+#include "util.h"
#include "prototype.h"
/* Access functions
void
rd_field_set_data(t_rdata_field *rd, uint8_t *d, uint16_t s)
{
- rd->_data = xmalloc(s);
+ XMALLOC(rd->_data, uint8_t, s);
memcpy(rd->_data, d, s);
}
rd_field_new(uint16_t s, t_rd_type t, uint8_t *d)
{
t_rdata_field *rd;
- rd = xmalloc(sizeof(t_rdata_field));
-
+ MALLOC(rd, t_rdata_field);
if (!rd)
return NULL;
rd_field_new_frm_string(t_rd_type t, char *s)
{
t_rdata_field *new;
- new = xmalloc(sizeof(t_rdata_field));
+ new = malloc(1 * sizeof t_rdata_field ) ;
- if (NULL == new)
+ if (!new)
return NULL;
rd_field_set_size(new, (uint16_t)strlen(s));
#include "rdata.h"
#include "rr.h"
#include "prototype.h"
+#include "util.h"
/**
* create a new rr structure.
rr_new(void)
{
t_rr *rr;
- rr = xmalloc(sizeof(t_rr));
-
+ MALLOC(rr, t_rr);
if (!rr)
return NULL;
#include "rr.h"
#include "packet.h"
#include "prototype.h"
+#include "util.h"
int
main(void)
xprintf_rr(rr);
- wire = xmalloc(100);
+ XMALLOC(wire, uint8_t, 100);
wire[0] = 0xc2;
wire[1] = 0xb4;
wire[2] = 0x81;
#include "rdata.h"
#include "rr.h"
-void *
-xmalloc(size_t s)
-{
- void *p;
- p = (void*)malloc(s);
- return p;
-}
-
-void *
-xrealloc(void *p, size_t s)
-{
- p = (void*)realloc(p, s);
- return p;
-}
-
/* put this here tmp. for debugging */
void
xprintf_rd_field(t_rdata_field *rd)