Unbound 1.4.21 - How do I get stats object on own method to display all available stats

Hi All,
I am trying to create a stats object on my method to display stats on console. But, I am getting seg. fault when I do like this.

int numport;
int* shufport;
int i = 0, j;
shufport = (int*)calloc(65536, sizeof(int));
int availPorts = 0;
for(j=0; j<65536; j++) {
if(daemon->cfg->outgoing_avail_ports[j]) {
shufport[availPorts++] = daemon->cfg->
outgoing_avail_ports[j];
}
}
if(availPorts == 0)
fatal_exit("no ports are permitted for UDP, add "
“with outgoing-port-permit”);
log_info(“No.of ports = %d”, availPorts);
numport = availPorts;
daemon->num = (daemon->cfg->num_threads?daemon->cfg->num_threads:1);
log_info(“Daemon number = %d”, daemon->num);

struct worker worker = worker_create(daemon, i, shufport+numporti/daemon->num,numport*(i+1)/daemon->num - numport*i/daemon->num);

log_info(“Worker created”);

struct server_stats *stats = &worker->stats;

log_info(“Server stats obj created”);

log_info(“Zone queries = %ld”, (long)stats->num_queries);

log_info("server stats %u queries, "
“%u answers from cache, %u recursions, %u prefetch”,
(unsigned)stats->num_queries,
(unsigned)(stats->num_queries -
stats->num_queries_missed_cache),
(unsigned)stats->num_queries_missed_cache,
(unsigned)stats->num_queries_prefetch);

I am running this code in an infinite loop “while(1)”, I am getting all 0 values, I am doing DIG in other tab still it is displaying 0 values.