include/_vec.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vec

Defines

#define GROWTHFACTOR   2
#define VEC_DELETE_INPLACE(vec)   free((vec)->vector)
#define VEC_LENGTH(vec)   ((vec)->len)
#define VEC_ERR(vec)   ((vec)->err)

Functions

int vec_init_inplace (unsigned long int initsize, struct vec *vec)
int vec_read_inplace (int srcfd, struct vec *vec, unsigned int size)
int vec_expand (struct vec *vec, unsigned int size)


Define Documentation

#define GROWTHFACTOR   2

Definition at line 15 of file _vec.h.

Referenced by vec_putvbyte().

#define VEC_DELETE_INPLACE ( vec   )     free((vec)->vector)

Definition at line 35 of file _vec.h.

#define VEC_ERR ( vec   )     ((vec)->err)

Definition at line 42 of file _vec.h.

#define VEC_LENGTH ( vec   )     ((vec)->len)

Definition at line 40 of file _vec.h.


Function Documentation

int vec_expand ( struct vec vec,
unsigned int  size 
)

Definition at line 189 of file vec.c.

References vec::err, vec::size, and vec::vector.

Referenced by vec_append(), and vec_putvbyte().

00189                                                  {
00190     /* grow the buffer (+ 1 is to step around case where size is 0) */
00191     void* newmem = realloc(v->vector, size);
00192 
00193     if (newmem) {
00194         v->size = size;
00195         v->vector = newmem;
00196         return 1;
00197     } else {
00198         v->err = ENOMEM;
00199         return 0;
00200     }
00201 }

Here is the caller graph for this function:

int vec_init_inplace ( unsigned long int  initsize,
struct vec vec 
)

Definition at line 25 of file vec.c.

References vec::err, vec::len, vec::pos, vec::size, and vec::vector.

00025                                                                 {
00026     if ((v->vector = malloc(initsize))) {
00027         v->size = initsize;
00028         v->pos = v->len = 0;
00029         v->err = 0;
00030         return 1;
00031     } else {
00032         return 0;
00033     }
00034 }

int vec_read_inplace ( int  srcfd,
struct vec vec,
unsigned int  size 
)

Definition at line 236 of file vec.c.

References vec::err, vec::len, vec::pos, vec::size, and vec::vector.

Referenced by vec_read().

00236                                                                  {
00237     if ((v->vector = malloc(len))) {
00238         unsigned int rlen;
00239         char *dst = v->vector;
00240         unsigned int size = len;
00241 
00242         while (len && ((rlen = read(srcfd, dst, len)) > 0)) {
00243             len -= rlen;
00244             dst += rlen;
00245         }
00246 
00247         if (!len) {
00248             v->len = v->size = size;
00249             v->pos = 0;
00250             v->err = 0;
00251             return 1;
00252         } else {
00253             free(v->vector);
00254             return 0;
00255         } 
00256     } else {
00257         return 0;
00258     }
00259 }

Here is the caller graph for this function:


Generated on Wed Dec 19 20:48:54 2007 for fsa-blast by  doxygen 1.5.2