- zero first element in idarray just in case
authorMichael Schroeder <mls@suse.de>
Wed, 24 Oct 2007 09:59:42 +0000 (09:59 +0000)
committerMichael Schroeder <mls@suse.de>
Wed, 24 Oct 2007 09:59:42 +0000 (09:59 +0000)
- make runtest compare with solution2 and solution3
- do not add same language solvables multiple times, fixes
  one test case

src/source.c
src/source_solv.c

index 2e140b3..d776f7c 100644 (file)
@@ -40,7 +40,7 @@ pool_addsource_empty(Pool *pool)
 
 /*
  * add Id to source
- * olddeps = offset into idarraydata
+ * olddeps = old array to extend
  * 
  */
 
@@ -54,22 +54,23 @@ source_addid(Source *source, Offset olddeps, Id id)
   idarray = source->idarraydata;
   idarraysize = source->idarraysize;
 
-  if (!idarray)                               /* check idarray size */
+  if (!idarray)                               /* alloc idarray if not done yet */
     {
       idarray = (Id *)xmalloc((1 + IDARRAY_BLOCK) * sizeof(Id));
+      idarray[0] = 0;
       idarraysize = 1;
       source->lastoff = 0;
     }
 
-  if (!olddeps)                               /* no deps yet */
+  if (!olddeps)                                /* no deps yet */
     {   
       olddeps = idarraysize;
       if ((idarraysize & IDARRAY_BLOCK) == 0)
         idarray = (Id *)xrealloc(idarray, (idarraysize + 1 + IDARRAY_BLOCK) * sizeof(Id));
     }   
-  else if (olddeps == source->lastoff) /* append at end */
+  else if (olddeps == source->lastoff) /* extend at end */
     idarraysize--;
-  else                                /* check space */
+  else                                 /* can't extend, copy old */
     {
       i = olddeps;
       olddeps = idarraysize;
@@ -83,12 +84,12 @@ source_addid(Source *source, Offset olddeps, Id id)
         idarray = (Id *)xrealloc(idarray, (idarraysize + 1 + IDARRAY_BLOCK) * sizeof(Id));
     }
   
-  idarray[idarraysize++] = id;        /* insert Id into array */
+  idarray[idarraysize++] = id;         /* insert Id into array */
 
   if ((idarraysize & IDARRAY_BLOCK) == 0)   /* realloc if at block boundary */
     idarray = (Id *)xrealloc(idarray, (idarraysize + 1 + IDARRAY_BLOCK) * sizeof(Id));
 
-  idarray[idarraysize++] = ID_NULL;    /* ensure NULL termination */
+  idarray[idarraysize++] = 0;          /* ensure NULL termination */
 
   source->idarraydata = idarray;
   source->idarraysize = idarraysize;
@@ -183,6 +184,7 @@ source_reserve_ids(Source *source, unsigned int olddeps, int num)
     {
       source->idarraysize = 1;
       source->idarraydata = (Id *)xmalloc(((1 + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id));
+      source->idarraydata[0] = 0;
       source->lastoff = 1;
       return 1;
     }
index d9a8311..3c14d23 100644 (file)
@@ -480,10 +480,11 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename)
     }
   if (size_idarray)
     {
-      size_idarray++;  /* first entry is not used */
+      size_idarray++;  /* first entry is always zero */
       source->idarraydata = (Id *)xmalloc(sizeof(Id) * size_idarray);
       source->idarraysize = size_idarray;
-      idarraydatap = source->idarraydata + 1;
+      idarraydatap = source->idarraydata;
+      *idarraydatap++ = 0;
       idarraydataend = source->idarraydata + size_idarray;
     }
   else