/* ** (c) COPYRIGHT MIT 1995. ** Please first read the full copyright statement in the file COPYRIGH. */This module implements a flexible array. It is a general utility module. A chunk is a structure which may be extended. These routines create and append data to chunks, automatically reallocating them as necessary. It is garanteed that the array is '\0' terminated at all times, so the terminating function, HTChunkTerminate is only necessary to adjust the size in the chunk structure (the '\0' counts as a character when counting the size of the chunk.
This module is implemented by HTChunk.c, and it is a part of the W3C Reference Library.
The names
without a "_" (made as a
#define
's) are only provided for
backwards compatibility and should not be used.
#ifndef HTCHUNK_H #define HTCHUNK_H
typedef struct { int size; /* In bytes */ int growby; /* Allocation unit in bytes */ int allocated; /* Current size of *data */ char * data; /* Pointer to malloced area or 0 */ } HTChunk;
#define HTChunkCreate(growby) HTChunk_new(growby) extern HTChunk * HTChunk_new (int growby);
HTChunkCreate
from memory
#define HTChunkFree(ch) HTChunk_delete(ch) extern void HTChunk_delete (HTChunk * ch);
#define HTChunkClear(ch) HTChunk_clear(ch) extern void HTChunk_clear (HTChunk * ch);
#define HTChunkEnsure(ch, s) HTChunk_ensure(ch, s) extern void HTChunk_ensure (HTChunk * ch, int s);
#define HTChunkPutc(ch, c) HTChunk_putc(ch, c) extern void HTChunk_putc (HTChunk * ch, char c);
#define HTChunkPuts(ch, str) HTChunk_puts(ch, str) extern void HTChunk_puts (HTChunk * ch, CONST char *str);
extern void HTChunk_putb (HTChunk * ch, CONST char *block, int len);
#define HTChunkTerminate(ch) HTChunk_terminate(ch) #define HTChunk_terminate(ch) HTChunk_putc((ch), '\0')
#define HTChunkData(me) ((me) ? (me)->data : NULL) #define HTChunk_data(me) ((me) ? (me)->data : NULL)
#define HTChunkSize(me) ((me) ? (me)->size : -1) #define HTChunk_size(me) ((me) ? (me)->size : -1)
#endifEnd of Declaration