TPCCLIB
Loading...
Searching...
No Matches
sif.c
Go to the documentation of this file.
1
5/*****************************************************************************/
7char siferrmsg[128];
8/*****************************************************************************/
9#include "libtpcimgio.h"
10/*****************************************************************************/
11
12/*****************************************************************************/
19 SIF *data
20) {
21 if(SIF_TEST) printf("sifInit()\n");
22 if(data==NULL) return;
23 memset(data, 0, sizeof(SIF));
24 data->frameNr=data->colNr=0;
25}
26/*****************************************************************************/
27
28/*****************************************************************************/
35 SIF *data
36) {
37 if(SIF_TEST) printf("sifEmpty()\n");
38 if(data==NULL) return;
39 if(data->frameNr>0) {
40 free((char*)(data->x1)); free((char*)(data->x2));
41 free((char*)(data->prompts)); free((char*)(data->randoms));
42 free((char*)(data->trues)); free((char*)(data->weights));
43 data->frameNr=data->colNr=0;
44 }
45 data->scantime=(time_t)0; data->version=0;
46 strcpy(data->studynr, ""); strcpy(data->isotope_name, "");
47}
48/*****************************************************************************/
49
50/*****************************************************************************/
58 SIF *data,
60 int frameNr
61) {
62 if(SIF_TEST) printf("sifSetmem()\n");
63 if(data==NULL) return(1);
64 /* Clear previous data, if necessary */
65 if(data->frameNr>0) sifEmpty(data);
66 if(frameNr<1) return(0);
67
68 /* Allocate memory */
69 data->x1=(double*)calloc(frameNr, sizeof(double));
70 data->x2=(double*)calloc(frameNr, sizeof(double));
71 data->prompts=(double*)calloc(frameNr, sizeof(double));
72 data->randoms=(double*)calloc(frameNr, sizeof(double));
73 data->trues=(double*)calloc(frameNr, sizeof(double));
74 data->weights=(double*)calloc(frameNr, sizeof(double));
75 if(data->x1==NULL || data->x2==NULL || data->prompts==NULL ||
76 data->randoms==NULL || data->trues==NULL || data->weights==NULL) {
77 strcpy(siferrmsg, "out of memory"); return(1);}
78 data->frameNr=frameNr;
79
80 return(0);
81}
82/*****************************************************************************/
83
84/*****************************************************************************/
Header file for libtpcimgio.
void sifInit(SIF *data)
Definition sif.c:17
int SIF_TEST
Definition sif.c:6
int sifSetmem(SIF *data, int frameNr)
Definition sif.c:56
void sifEmpty(SIF *data)
Definition sif.c:33
char siferrmsg[128]
Definition sif.c:7
double * x1
double * prompts
int frameNr
double * x2
int version
char studynr[MAX_STUDYNR_LEN+1]
time_t scantime
char isotope_name[8]
double * weights
int colNr
double * randoms
double * trues