]> arthur.barton.de Git - ngircd-alex.git/commitdiff
array_get: no need to multiply again. remove unneeded checks. remove array_free_wipe().
authorFlorian Westphal <fw@strlen.de>
Sat, 30 Sep 2006 21:49:46 +0000 (21:49 +0000)
committerFlorian Westphal <fw@strlen.de>
Sat, 30 Sep 2006 21:49:46 +0000 (21:49 +0000)
src/ngircd/array.c

index 6e96bd56b0d5635324e8c04f71f41f4b4b94d66a..bc28d042fdd4e65d8aba29b5e1760a2f31137bbc 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "array.h"
 
 
 #include "array.h"
 
-static char UNUSED id[] = "$Id: array.c,v 1.11 2006/07/01 22:11:48 fw Exp $";
+static char UNUSED id[] = "$Id: array.c,v 1.12 2006/09/30 21:49:46 fw Exp $";
 
 #include <assert.h>
 
 
 #include <assert.h>
 
@@ -66,10 +66,7 @@ array_alloc(array * a, size_t size, size_t pos)
 
        assert(size > 0);
 
 
        assert(size > 0);
 
-       if (pos_plus1 < pos)
-               return NULL;
-
-       if (!safemult_sizet(size, pos_plus1, &alloc))
+       if (pos_plus1 == 0 || !safemult_sizet(size, pos_plus1, &alloc))
                return NULL;
 
        if (a->allocated < alloc) {
                return NULL;
 
        if (a->allocated < alloc) {
@@ -263,7 +260,7 @@ array_get(array * a, size_t membersize, size_t pos)
        if (a->allocated < totalsize)
                return NULL;
 
        if (a->allocated < totalsize)
                return NULL;
 
-       return a->mem + pos * membersize;
+       return a->mem + totalsize;
 }
 
 
 }
 
 
@@ -283,16 +280,6 @@ array_free(array * a)
 }
 
 
 }
 
 
-void
-array_free_wipe(array * a)
-{
-       if (!array_UNUSABLE(a))
-               memset(a->mem, 0, a->allocated);
-
-       array_free(a);
-}
-
-
 void *
 array_start(const array * const a)
 {
 void *
 array_start(const array * const a)
 {
@@ -331,9 +318,6 @@ array_moveleft(array * a, size_t membersize, size_t pos)
        assert(a != NULL);
        assert(membersize > 0);
 
        assert(a != NULL);
        assert(membersize > 0);
 
-       if (!pos)
-               return;
-
        if (!safemult_sizet(membersize, pos, &bytepos)) {
                a->used = 0;
                return;
        if (!safemult_sizet(membersize, pos, &bytepos)) {
                a->used = 0;
                return;