#include<stdio.h>
#include<stdlib.h>

#include"zither_lint.h"
#include<almemsys/almemsys.h>


extern global_data_t gd;

int malloc_set(void)
{
int count, count2;

if((gd.filename = (char *)calloc((BUF_DEFLEN + 5), sizeof(char)))==NULL){
   exit(1);
   }
if((gd.pg_host = (char *)calloc((BUF_DEFLEN + 5), sizeof(char)))==NULL){
   exit(1);
   }
if((gd.pg_hostdata = (char *)calloc((BUF_DEFLEN + 5), sizeof(char)))==NULL){
   exit(1);
   }
if((gd.pg_dbname = (char *)calloc((BUF_DEFLEN + 5), sizeof(char)))==NULL){
   exit(1);
   }

if((gd.lendata=(char ***)malloc(sizeof(char **) * (BUF_MAX + 5)))==NULL){
   exit(1);
   }
for(count = 0; count <= BUF_MAX; count++){
   if((gd.lendata[count]=(char **)malloc(sizeof(char *) * (BUF_MAX + 5)))==NULL){
      exit(1);
      }
   for(count2 = 0; count2 <= 14; count2++){
      if((gd.lendata[count][count2]=(char *)calloc(2, sizeof(char)))==NULL){exit(1);}
      }
   }

return 0;
}


int malloc_free(void)
{
int count, count2;

free(gd.filename);
free(gd.pg_host);
free(gd.pg_hostdata);
free(gd.pg_dbname);

for(count = 0; count <= BUF_MAX; count++){
   for(count2 = 0; count2 <= 14; count2++){
      free(gd.lendata[count][count2]);
      }
   free(gd.lendata[count]);
   }

free(gd.lendata);

return 0;
}


