Make 'allocated' an integer in vector.h
authorHannes Reinecke <hare@suse.de>
Tue, 8 Jan 2013 13:54:10 +0000 (14:54 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 8 Jan 2013 23:20:19 +0000 (00:20 +0100)
I don't trust the programmers here, as we're unconditionally
decreasing the 'allocated' setting on vector_free().
So better make that an integer to catch underflows.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/vector.c
libmultipath/vector.h

index 7159b7e..6266e0a 100644 (file)
@@ -117,7 +117,7 @@ vector_del_slot(vector v, int slot)
 
        v->allocated -= VECTOR_DEFAULT_SIZE;
 
-       if (!v->allocated) {
+       if (v->allocated <= 0) {
                FREE(v->slot);
                v->slot = NULL;
                v->allocated = 0;
index 6779186..7612b4c 100644 (file)
@@ -25,7 +25,7 @@
 
 /* vector definition */
 struct _vector {
-       unsigned int allocated;
+       int allocated;
        void **slot;
 };
 typedef struct _vector *vector;