libmib astring usage

There are just a few simple points for creating, using and and destroying astrings, as represented in the following example code:
        char *pasz = 0; /* Always initialize an astring to 0 before use */
	int ind;
	for(ind = 0;ind < 1000;ind++) {
	    astrcat(&pasz,"Repeat"); /* use astring equivalents for
					  str[n]cpy and str[n]cat */
	printf("Length: %d\n",strlen(pasz)); /* use pasz as a regular 'char *' */
	astrfree(&pasz); /* use astrfree() or free() to prevent leaks. */

        char *ppasz = 0;

    char *astrcpy(char **ppasz,const char *pSrc);
    char *astrn0cpy(char **ppasz,const char *pSrc,int n);
	/* NOTE: astrn0cpy Always stores the ending \0 */

    char *astrcat(char **ppasz,const char *pszSrc);
    char *astrn0cat(char **ppasz,const char *pSrc,int n);
	/* NOTE: astrn0cat Always stores the ending \0 */
    int avsprintf(char **ppasz, const char *format,va_list ap);
    int asprintf(char **ppasz, const char *format,...);
    char *afgets(char **ppasz,FILE *f);
    int afgettoch(char **ppasz,FILE *f, char chStop)
	/* Reads up to and including the next chStop character,
	   storing a \0 afterwards.  Returns number of characters read. */
astring advanced usage discusses adjusting the implementation strategies and settings for efficiency and debugging, as well as how to use astrensure() and astrstatic() for creating functions which extend and shrink the buffer.

More Detailed Topics

Get the Source
astring advanced usage
Using astrensure() to write your own limitless string functions.

Example: an "fgrep-like" filter using astrings easily handles unlimited line lengths in a small amount of code.

Overview and Related Topics
Up to: Libmib Allocated String Functions
Up to: Libmib: Character String Processing
Up to: Libmib

This Libmib documentation may not be distributed. Copyright 1998, Forrest J. Cavalier III
Mib Software
High Reuse Software Development