Annotation of libwww/Library/src/HTChunk.html, revision 2.7

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
2.7     ! timbl       8: and append data to chunks, automatically
2.6       timbl       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
2.7     ! timbl      33: <DD> The number of bytes to allocate
2.6       timbl      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
2.7     ! timbl      42: <DD> A chunk pointer to the new
2.6       timbl      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
2.7     ! timbl      55: <DD> A valid chunk pointer made by
        !            56: HTChunkCreate()
2.6       timbl      57: </DL>
                     58: 
                     59: <H3>On exit,</H3>
                     60: <DL>
                     61: <DT>ch
2.7     ! timbl      62: <DD> is invalid and may not be used.
2.6       timbl      63: </DL>
                     64: 
                     65: <PRE>
2.1       timbl      66: extern void HTChunkFree PARAMS((HTChunk * ch));
                     67: 
                     68: 
2.6       timbl      69: </PRE>
                     70: <H2>Clear a chunk</H2>
                     71: <H3>On entry,</H3>
                     72: <DL>
                     73: <DT>ch
2.7     ! timbl      74: <DD> A valid chunk pointer made by
        !            75: HTChunkCreate()
2.6       timbl      76: </DL>
                     77: 
                     78: <H3>On exit,</H3>
                     79: <DL>
                     80: <DT>*ch
2.7     ! timbl      81: <DD> The size of the chunk is zero.
2.6       timbl      82: </DL>
                     83: 
                     84: <PRE>
2.1       timbl      85: extern void HTChunkClear PARAMS((HTChunk * ch));
                     86: 
                     87: 
2.6       timbl      88: </PRE>
                     89: <H2>Ensure a chunk has a certain space
                     90: in</H2>
                     91: <H3>On entry,</H3>
                     92: <DL>
                     93: <DT>ch
2.7     ! timbl      94: <DD> A valid chunk pointer made by
        !            95: HTChunkCreate()
2.6       timbl      96: <DT>s
2.7     ! timbl      97: <DD> The size required
2.6       timbl      98: </DL>
                     99: 
                    100: <H3>On exit,</H3>
                    101: <DL>
                    102: <DT>*ch
2.7     ! timbl     103: <DD> Has size at least s
2.6       timbl     104: </DL>
                    105: 
                    106: <PRE>
2.1       timbl     107: extern void HTChunkEnsure PARAMS((HTChunk * ch, int s));
                    108: 
                    109: 
2.6       timbl     110: </PRE>
                    111: <H2>Append a character to a  chunk</H2>
                    112: <H3>On entry,</H3>
                    113: <DL>
                    114: <DT>ch
2.7     ! timbl     115: <DD> A valid chunk pointer made by
        !           116: HTChunkCreate()
        !           117: <DT>c
        !           118: <DD>The character to be appended
2.6       timbl     119: </DL>
                    120: 
2.7     ! timbl     121: <H3>On exit,</H3>
        !           122: <DL>
        !           123: <DT>*ch
        !           124: <DD>Is one character bigger
        !           125: </DL>
2.1       timbl     126: 
2.7     ! timbl     127: <PRE>extern void HTChunkPutc PARAMS((HTChunk * ch, char c));
2.1       timbl     128: 
2.6       timbl     129: </PRE>
                    130: <H2>Append a string to a  chunk</H2>
                    131: <H3>On entry,</H3>
                    132: <DL>
                    133: <DT>ch
2.7     ! timbl     134: <DD> A valid chunk pointer made by
        !           135: HTChunkCreate()
        !           136: <DT>str
        !           137: <DD> Tpoints to a zero-terminated
        !           138: string to be appended
2.6       timbl     139: </DL>
                    140: 
                    141: <H3>On exit,</H3>
                    142: <DL>
                    143: <DT>*ch
2.7     ! timbl     144: <DD> Is bigger by strlen(str)
2.6       timbl     145: </DL>
                    146: 
                    147: <PRE>
2.1       timbl     148: 
2.7     ! timbl     149: extern void HTChunkPuts PARAMS((HTChunk * ch, const char *str));
2.1       timbl     150: 
                    151: 
2.6       timbl     152: </PRE>
                    153: <H2>Append a zero character to a  chunk</H2>
                    154: <PRE>
                    155: </PRE>
                    156: <H3>On entry,</H3>
                    157: <DL>
                    158: <DT>ch
2.7     ! timbl     159: <DD> A valid chunk pointer made by
        !           160: HTChunkCreate()
2.6       timbl     161: </DL>
                    162: 
                    163: <H3>On exit,</H3>
                    164: <DL>
                    165: <DT>*ch
2.7     ! timbl     166: <DD> Is one character bigger
2.6       timbl     167: </DL>
                    168: 
                    169: <PRE>
2.1       timbl     170: 
                    171: extern void HTChunkTerminate PARAMS((HTChunk * ch));
2.6       timbl     172: 
2.7     ! timbl     173: </PRE>end</BODY>

Webmaster