FACT++  1.0
char* createHeader ( unsigned int  id,
short  errorCode,
bool  huffmanFlag,
bool  checksumFlag,
int  checksum 
)

Definition at line 2315 of file feeserver.c.

References cleanUp(), createLogMessage(), and Memory::malloc().

Referenced by leaveCommandHandler(), and start().

2316  {
2317  char* pHeader = 0;
2318  FlagBits flags = NO_FLAGS;
2319 
2320  if (huffmanFlag) {
2321  //set huffman flag via binary OR
2322  flags |= HUFFMAN_FLAG;
2323  }
2324  if (checksumFlag) {
2325  //set checksum flag via binary OR
2326  flags |= CHECKSUM_FLAG;
2327  }
2328 
2329  pHeader = (char*) malloc(HEADER_SIZE);
2330  if (pHeader == 0) {
2331  //no memory available!
2332 # ifdef __DEBUG
2333  printf("no memory available while trying to create header!\n");
2334  fflush(stdout);
2335 # endif
2336  createLogMessage(MSG_ALARM,
2337  "No more memory available, unable to continue serving - exiting.",
2338  0);
2339  cleanUp();
2340  exit(201);
2341  }
2342 
2343  memcpy(pHeader, &id, HEADER_SIZE_ID);
2344  memcpy(pHeader + HEADER_OFFSET_ID, &errorCode, HEADER_SIZE_ERROR_CODE);
2345  memcpy(pHeader + HEADER_OFFSET_ERROR_CODE, &flags, HEADER_SIZE_FLAGS);
2346  memcpy(pHeader + HEADER_OFFSET_FLAGS, &checksum, HEADER_SIZE_CHECKSUM);
2347 
2348  return pHeader;
2349 }
void cleanUp()
Definition: feeserver.c:3159
void * malloc()
Definition: EventBuilder.cc:99
void createLogMessage(unsigned int type, char *description, char *origin)
Definition: feeserver.c:1530

+ Here is the call graph for this function:

+ Here is the caller graph for this function: