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

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

Webmaster