ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/vector.h
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/vector.h (file contents):
Revision 1.4 by ats, Mon Apr 5 00:45:17 2004 UTC vs.
Revision 1.5 by ats, Mon Apr 5 00:58:05 2004 UTC

# Line 7 | Line 7 | typedef struct {
7          size_t item_size;
8          int used_count;
9          int alloc_count;
10 +        int error;
11          int block_size;
12          vector_init_function init_fn;
13          vector_destroy_function destroy_fn;
# Line 17 | Line 18 | typedef struct {
18                  sizeof(item_type), \
19                  0, \
20                  0, \
21 +                0, \
22                  block_size, \
23                  (vector_init_function) init_fn, \
24                  (vector_destroy_function) destroy_fn \
25          }
26  
27 < /* A pointer value that won't be returned by malloc, and isn't NULL, so can be
26 < * used as a sentinel by allocation routines that need to return NULL
27 < * sometimes. */
28 < extern char statgrab_vector_sentinel_value;
29 < static void *statgrab_vector_sentinel = &statgrab_vector_sentinel_value;
30 <
31 < /* Internal function to resize the vector. Ideally it would take void ** as the
32 < * first parameter, but ANSI strict-aliasing rules would then prevent it from
33 < * doing anything with it, so we return a sentinel value as above instead if
34 < * allocation fails. */
27 > /* Internal function to resize the vector. */
28   void *statgrab_vector_resize(void *vector, vector_header *h, int count);
29  
30   /* Declare a vector. Specify the init/destroy functions as NULL if you don't
# Line 51 | Line 44 | void *statgrab_vector_resize(void *vector, vector_head
44  
45   /* Resize a vector. Returns 0 on success, -1 on out-of-memory. On
46   * out-of-memory, the old contents of the vector will be destroyed and the old
47 < * vector will be freed.
55 < *
56 < * This is ugly because it needs to check for the sentinel value.
57 < */
47 > * vector will be freed. */
48   #define VECTOR_RESIZE(name, num_items) \
49 <        (((name = statgrab_vector_resize((char *) name, &name##_header, num_items)) \
50 <          == statgrab_vector_sentinel) ? -1 : 0)
49 >        (name = statgrab_vector_resize((char *) name, &name##_header, num_items), \
50 >         name##_header.error)
51  
52   /* Free a vector, destroying its contents. */
53   #define VECTOR_FREE(name) \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines