common.c File Reference
Commonly used routines.
More...
#include "log.h"
#include "linestream.h"
#include "common.h"
Go to the source code of this file.
|
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 *vpt) |
| 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
Commonly used routines.
- Author:
- Adapted by Lukas Habegger (lukas.habegger@yale.edu)
Definition in file common.c.
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.