I am trying to allocate values at two different stages of the code
Code:
//FIRST STAGE
pntr[0]->srvr->stage->final=(unihash*)malloc(sizeof(unihash)*(strlen(line2))*(cnt+2));
strcpy(pntr[0]->srvr->stage->final[cnt].key,first);
strcpy(pntr[0]->srvr->stage->final[cnt].value,secon);
free(pntr[0]->srvr->stage->final);
cnt++;
// SECOND STAGE
pntr[1]->srvr->stage->final = malloc(sizeof(unihash)*(9600)+1);
strcpy(pntr[1]->srvr->stage->final[cnt].key,first);
strcpy(pntr[1]->srvr->stage->final[cnt].value,secon);
free(pntr[1]->srvr->stage->final);
cnt++;
I find that when I try to access the pntr[1]->srvr->stage->final, all the key-values assigned to pntr[0]->srvr->stage->final[cnt].value
have moved to the pntr[1]->srvr->stage->final.
Code:
for(n=0 ; n < d; n++){
printf(" %d %d pntr[1]->bee->stg->maindbm %s %s \n",m,n,pntr[1]->bee->stg->maindbm[n].key,pntr[1]->bee->stg->maindbm[n].value);
}
Is there any way I can keep the contents of pntr[0]->srvr->stage->final away from pntr[1]->srvr->stage->final.