Back to index

tetex-bin  3.0
Classes | Functions
trace_buf.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Classes

struct  LIST

Functions

static char * _nc_trace_alloc (int bufnum, size_t want)
 _nc_trace_buf (int bufnum, size_t want)
 _nc_trace_bufcat (int bufnum, const char *value)

Class Documentation

struct LIST

Definition at line 40 of file trace_buf.c.

Class Members
size_t size
char * text

Function Documentation

static char* _nc_trace_alloc ( int  bufnum,
size_t  want 
) [static]

Definition at line 46 of file trace_buf.c.

{
    char *result = 0;
    static LIST *list;
    static size_t have;

    if (bufnum >= 0) {
       if ((size_t) (bufnum + 1) > have) {
           size_t need = (bufnum + 1) * 2;
           if ((list = typeRealloc(LIST, need, list)) == 0)
              return (0);
           while (need > have)
              list[have++].text = 0;
       }

       if (list[bufnum].text == 0
           || want > list[bufnum].size) {
           if ((list[bufnum].text = typeRealloc(char, want, list[bufnum].text))
              != 0)
                list[bufnum].size = want;
       }

       result = list[bufnum].text;
    }
#if NO_LEAKS
    else {
       if (have) {
           while (have--) {
              if (list[have].text != 0)
                  free(list[have].text);
           }
           free(list);
       }
    }
#endif
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

_nc_trace_buf ( int  bufnum,
size_t  want 
)

Definition at line 88 of file trace_buf.c.

{
    char *result = _nc_trace_alloc(bufnum, want);
    if (result != 0)
       *result = '\0';
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

_nc_trace_bufcat ( int  bufnum,
const char *  value 
)

Definition at line 100 of file trace_buf.c.

{
    char *buffer = _nc_trace_alloc(bufnum, 0);
    size_t have = strlen(buffer);

    buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value));
    (void) strcpy(buffer + have, value);

    return buffer;
}

Here is the call graph for this function: