Changeset 1652 for zzuf


Ignore:
Timestamp:
Jan 11, 2007, 11:43:45 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Reduce number of malloc() calls within libzzuf.
Location:
zzuf/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/fd.c

    r1651 r1652  
    3636
    3737/* File descriptor stuff */
     38/* TODO: split this into a static table of around 32 file descriptors, for
     39 * most common uses, and a dynamic table for optional additional fds. */
    3840static struct files
    3941{
     
    6264void _zz_fd_init(void)
    6365{
    64     files = NULL;
    65     nfiles = 0;
     66    /* We start with 32 file descriptors. This is to reduce the number of
     67     * calls to malloc() that we do, so we get better chances that memory
     68     * corruption errors are reproducible */
     69    files = malloc(32 * sizeof(*files));
     70    for(nfiles = 0; nfiles < 32; nfiles++)
     71        files[nfiles].managed = 0;
    6672
    67     /* Start with one fd in the lookup table */
    68     fds = malloc(1 * sizeof(int));
    69     for(maxfd = 0; maxfd < 1; maxfd++)
     73    fds = malloc(32 * sizeof(int));
     74    for(maxfd = 0; maxfd < 32; maxfd++)
    7075        fds[maxfd] = -1;
    7176}
     
    137142    files[i].pos = 0;
    138143    files[i].fuzz.cur = -1;
    139     files[i].fuzz.data = malloc(CHUNKBYTES);
    140144#ifdef HAVE_FGETLN
    141145    files[i].fuzz.tmp = NULL;
     
    151155
    152156    files[fds[fd]].managed = 0;
    153     free(files[fds[fd]].fuzz.data);
    154157#ifdef HAVE_FGETLN
    155158    if(files[fds[fd]].fuzz.tmp)
  • zzuf/trunk/src/libzzuf.h

    r1641 r1652  
    2929{
    3030    int cur;
    31     uint8_t *data;
    3231#ifdef HAVE_FGETLN
    3332    char *tmp;
    3433#endif
     34    uint8_t data[CHUNKBYTES];
    3535};
    3636
Note: See TracChangeset for help on using the changeset viewer.