Annotation of libwww/Library/src/HTChunk.html, revision 2.6
2.6 ! timbl 1: <HEADER>
! 2: <TITLE>/Net/dxcern/userd/timbl/hypertext/WWW/Library/Implementation/HTChunk.html</TITLE></HEADER>
! 3: <BODY>
! 4: <H1>Chunk handling: Flexible arrays</H1>This module implements a flexible
! 5: array. It is a general utility module.
! 6: A chunk is a structure which may
! 7: be extended. These routines create
! 8: and append data to chunks, automatically
! 9: reallocating them as necessary.
! 10: <PRE>typedef struct {
2.1 timbl 11: int size; /* In bytes */
12: int growby; /* Allocation unit in bytes */
13: int allocated; /* Current size of *data */
14: char * data; /* Pointer to malloced area or 0 */
15: } HTChunk;
16:
17:
18: #ifdef SHORT_NAMES
19: #define HTChunkClear HTChClea
20: #define HTChunkPutc HTChPutc
21: #define HTChunkPuts HTChPuts
22: #define HTChunkCreate HTChCrea
23: #define HTChunkTerminate HTChTerm
24: #define HTChunkEnsure HtChEnsu
25: #endif
26:
27:
2.6 ! timbl 28: </PRE>
! 29: <H2>Create new chunk</H2>
! 30: <H3>On entry,</H3>
! 31: <DL>
! 32: <DT>growby
! 33: <DD>The number of bytes to allocate
! 34: at a time when the chunk is later
! 35: extended. Arbitrary but normally
! 36: a trade-off time vs. memory
! 37: </DL>
! 38:
! 39: <H3>On exit,</H3>
! 40: <DL>
! 41: <DT>returns
! 42: <DD>A chunk pointer to the new
! 43: chunk,
! 44: </DL>
! 45:
! 46: <PRE>
2.1 timbl 47: extern HTChunk * HTChunkCreate PARAMS((int growby));
48:
49:
2.6 ! timbl 50: </PRE>
! 51: <H2>Free a chunk</H2>
! 52: <H3>On entry,</H3>
! 53: <DL>
! 54: <DT>ch
! 55: <DD>A valid chunk pointer made by HTChunkCreate()
! 56: </DL>
! 57:
! 58: <H3>On exit,</H3>
! 59: <DL>
! 60: <DT>ch
! 61: <DD>is invalid and may not be used.
! 62: </DL>
! 63:
! 64: <PRE>
2.1 timbl 65: extern void HTChunkFree PARAMS((HTChunk * ch));
66:
67:
2.6 ! timbl 68: </PRE>
! 69: <H2>Clear a chunk</H2>
! 70: <H3>On entry,</H3>
! 71: <DL>
! 72: <DT>ch
! 73: <DD>A valid chunk pointer made by HTChunkCreate()
! 74: </DL>
! 75:
! 76: <H3>On exit,</H3>
! 77: <DL>
! 78: <DT>*ch
! 79: <DD>The size of the chunk is zero.
! 80: </DL>
! 81:
! 82: <PRE>
2.1 timbl 83: extern void HTChunkClear PARAMS((HTChunk * ch));
84:
85:
2.6 ! timbl 86: </PRE>
! 87: <H2>Ensure a chunk has a certain space
! 88: in</H2>
! 89: <H3>On entry,</H3>
! 90: <DL>
! 91: <DT>ch
! 92: <DD>A valid chunk pointer made by HTChunkCreate()
! 93: <DT>s
! 94: <DD>The size required
! 95: </DL>
! 96:
! 97: <H3>On exit,</H3>
! 98: <DL>
! 99: <DT>*ch
! 100: <DD>Has size at least s
! 101: </DL>
! 102:
! 103: <PRE>
2.1 timbl 104: extern void HTChunkEnsure PARAMS((HTChunk * ch, int s));
105:
106:
2.6 ! timbl 107: </PRE>
! 108: <H2>Append a character to a chunk</H2>
! 109: <H3>On entry,</H3>
! 110: <DL>
! 111: <DT>ch
! 112: <DD>A valid chunk pointer made by HTChunkCreate()
! 113: </DL>
! 114:
! 115: <PRE>** c The character to be appended
2.1 timbl 116: ** On exit,
117: ** *ch Is one character bigger
118: */
119:
120: extern void HTChunkPutc PARAMS((HTChunk * ch, char c));
121:
2.6 ! timbl 122: </PRE>
! 123: <H2>Append a string to a chunk</H2>
! 124: <H3>On entry,</H3>
! 125: <DL>
! 126: <DT>ch
! 127: <DD>A valid chunk pointer made by HTChunkCreate()
! 128: <DT>s
! 129: <DD>Tpoints to a zero-terminated string
! 130: to be appended
! 131: </DL>
! 132:
! 133: <H3>On exit,</H3>
! 134: <DL>
! 135: <DT>*ch
! 136: <DD>Is bigger by strlen(s)
! 137: </DL>
! 138:
! 139: <PRE>
2.1 timbl 140:
141: extern void HTChunkPuts PARAMS((HTChunk * ch, const char *s));
142:
143:
2.6 ! timbl 144: </PRE>
! 145: <H2>Append a zero character to a chunk</H2>
! 146: <PRE>
! 147: </PRE>
! 148: <H3>On entry,</H3>
! 149: <DL>
! 150: <DT>ch
! 151: <DD>A valid chunk pointer made by HTChunkCreate()
! 152: </DL>
! 153:
! 154: <H3>On exit,</H3>
! 155: <DL>
! 156: <DT>*ch
! 157: <DD>Is one character bigger
! 158: </DL>
! 159:
! 160: <PRE>
2.1 timbl 161:
162: extern void HTChunkTerminate PARAMS((HTChunk * ch));
2.6 ! timbl 163:
! 164: </PRE>end</A></BODY>
Webmaster