
#include<stdio.h>
#include<netinet/in.h>
#include<stdlib.h>
#include<pthread.h>

#include"sitar.h"
#include"sitar_scan.h"
#include<almemsys/almemsys.h>


extern global_data_t gd;
extern swap_array_t sa;



int sacalloc(int count)
{
int count_t;

#ifdef MALLOC_BUG
printf("MALLOC: sacalloc():\n");
#endif

for(count_t = 0; count_t < gd.td.tbufmax; count_t ++){
   if((sa.swap_data[count][count_t]=(char *)calloc(BUF_LEN * 2, sizeof(char)))==NULL){exit(1);}
   #ifdef XMALLOC_BUG
   printf("MALLOC: sacalloc(): sa.swap_data[%d][%d]\n", count, count_t);
   #endif
   }
return 0;
}



int safree(int count)
{
int count_t;

#ifdef FREE_BUG
printf("FREE: safree():\n");
#endif

for(count_t = 0; count_t < gd.td.tbufmax; count_t ++){
   #ifdef XFREE_BUG
   printf("FREE: safree(): sa.swap_data[%d][%d] %s\n", count, count_t, sa.swap_data[count][count_t]);
   #endif
   free(sa.swap_data[count][count_t]);
   }
return 0;
}



int sanull(int count)
{
int count_t;

#ifdef FREE_BUG
printf("FREE: safree():\n");
#endif

for(count_t = 0; count_t < gd.td.tbufmax; count_t ++){
   #ifdef XFREE_BUG
   printf("FREE: sanull(): sa.swap_data[%d][%d] %s\n", count, count_t, sa.swap_data[count][count_t]);
   #endif
   sa.swap_data[count][count_t] = null_free(sa.swap_data[count][count_t]);
   }
return 0;
}






