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