common.h File Reference

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <stdio.h>
#include "format.h"

Go to the source code of this file.

Data Structures

struct  TableRow
 TableRow. More...

Defines

#define AllocA(type)   needMem(sizeof(type))
 Shortcut to allocating a variable on heap of a specific type.
#define AllocVar(pt)   (pt = needMem(sizeof(*pt)))
 Shortcut to allocating a single variable on the heap and assigning pointer to it.
#define CloneVar(pt)   cloneMem(pt, sizeof((pt)[0]))
 Allocate copy of a structure.

Functions

void * cloneMem (void *pt, size_t size)
 Allocate a new buffer of given size, and copy pt to it.
void freeMem (void *pt)
 Free memory will check for null before freeing.
void freez (void *ppt)
 Free pointer and set it to NULL.
void * needLargeMem (size_t size)
 Request a large block of memory.
void * needLargeMemResize (void *vp, size_t size)
 Adjust memory size on a block, possibly relocating it.
void * needLargeZeroedMem (size_t size)
 Request a large block of memory and zero it.
void * needLargeZeroedMemResize (void *vp, size_t oldSize, size_t newSize)
 Adjust memory size on a block, possibly relocating it.
void * needMem (size_t size)
 Request a block of memory.
Texta readList (char *fileName)
 Read a list from a file.
Array readTable (char *fileName, char *delimiter)
 Read a table from a file.
void reverseBytes (char *bytes, long length)
 Reverse the order of the bytes.
void zeroBytes (void *vpt, int count)
 Fill a specified area of memory with zeroes.


Detailed Description

Author:
Adapted by Lukas Habegger (lukas.habegger@yale.edu)

Definition in file common.h.


Function Documentation

void freez ( void *  vpt  ) 

Free pointer and set it to NULL.

s = needMem(1024); ... freez(&s);

Definition at line 135 of file common.c.

void* needLargeMem ( size_t  size  ) 

Request a large block of memory.

This calls abort if the memory allocation fails. The memory is not initialized to zero.

Definition at line 52 of file common.c.

void* needLargeMemResize ( void *  vp,
size_t  size 
)

Adjust memory size on a block, possibly relocating it.

If vp is NULL, a new memory block is allocated. Memory not initted.

Definition at line 78 of file common.c.

void* needLargeZeroedMemResize ( void *  vp,
size_t  oldSize,
size_t  newSize 
)

Adjust memory size on a block, possibly relocating it.

If vp is NULL, a new memory block is allocated. If block is grown, new memory is zeroed.

Definition at line 96 of file common.c.

void* needMem ( size_t  size  ) 

Request a block of memory.

Need mem calls abort if the memory allocation fails. The memory is initialized to zero.

Definition at line 38 of file common.c.

Texta readList ( char *  fileName  ) 

Read a list from a file.

Note:
Empty lines are skipped.

Definition at line 185 of file common.c.


Generated on Fri Aug 7 15:46:42 2009 for BIOS by  doxygen 1.5.7.1