Update of /cvsroot/monetdb/pathfinder/modules/pftijah
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14824

Modified Files:
        nexi.c nexi_generate_mil.c nexi_generate_plan.c pftijah.mx 
        serialize_pftijah.mx termdb.mx 
Log Message:

alloc() (in none of its flavors) is guaranteed to succeed;
hence, we should always check, whether alloc() succeeded (returned non-NULL)
or not.
For now, I only added assert()'s;
this should help to debug and eventually fix the segmentation faults
that occur (primarily) on SunOS.

I leave the proper (error-)handling of failing alloc()'s
to the respective owner(s)/maintainer(s) of the PFtijah code.


Index: serialize_pftijah.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/serialize_pftijah.mx,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- serialize_pftijah.mx        21 Mar 2007 07:35:29 -0000      1.45
+++ serialize_pftijah.mx        24 May 2007 13:10:24 -0000      1.46
@@ -953,12 +953,14 @@
         } else {
             //if (*res) GDKfree(*res);
             *res = GDKmalloc( strlen(stemmed)+1 );
+            assert(*res);
             strcpy( *res, stemmed );
         }
         //if ( stemCtx->clear ) stemCtx->clear( stemCtx );
     } else {
         //if (*res) GDKfree(*res);
         *res = GDKmalloc( strlen(term)+1 );
+        assert(*res);
         strcpy( *res, term );
     }
     return GDK_SUCCEED;

Index: nexi.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/nexi.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- nexi.c      7 May 2007 07:01:40 -0000       1.58
+++ nexi.c      24 May 2007 13:10:23 -0000      1.59
@@ -198,8 +198,11 @@
        This bug should be fixed now, with the cleanup of nexi_rewriter.c
     */
     txt_retr_model = calloc(MAX_QUERIES, sizeof(struct_RMT));
+    assert(txt_retr_model);
     img_retr_model = calloc(MAX_QUERIES, sizeof(struct_RMI));
+    assert(img_retr_model);
     rel_feedback = calloc(MAX_QUERIES, sizeof(struct_RF));
+    assert(rel_feedback);
 
     /*** Set default configuration values here: ***/
     
@@ -670,6 +673,7 @@
        tsl->cnt   = 0;
        tsl->max   = max;
        tsl->val   = GDKmalloc( tsl->max * sizeof(char*) );
+       assert(tsl->val);
        return 1;
 }
 
@@ -699,6 +703,7 @@
        if ( tsl->cnt >= tsl->max) {
                tsl->max *= 2;
                tsl->val = GDKrealloc(tsl->val,(tsl->max * sizeof(char*)));
+               assert(tsl->val);
        }
 #ifdef DEBUG_LIST
        stream_printf(GDKout,"# appending \"%s\" to LIST[%s].\n",v,tsl->label);
@@ -721,6 +726,7 @@
        tnl->cnt   = 0;
        tnl->max   = max;
        tnl->val   = GDKmalloc( tnl->max * sizeof(int) );
+       assert(tnl->val);
        return 1;
 }
 
@@ -744,6 +750,7 @@
        if ( tnl->cnt >= tnl->max) {
                tnl->max *= 2;
                tnl->val = GDKrealloc(tnl->val,tnl->max * sizeof(int));
+               assert(tnl->val);
        }
 #ifdef DEBUG_LIST
        stream_printf(GDKout,"# appending (%d) to LIST[%s].\n",v,tnl->label);

Index: termdb.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/termdb.mx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- termdb.mx   18 Jan 2007 18:18:57 -0000      1.7
+++ termdb.mx   24 May 2007 13:10:24 -0000      1.8
@@ -514,9 +514,11 @@
      *
      */
     tdb->hashbat= GDKrealloc(tdb->hashbat,1+(int)tdb->curFrag* sizeof(BAT*));
+    assert(tdb->hashbat);
     tdb->hashbat[new_fragIdx] = 0;
     if (tdb->hashbatSize) {
         tdb->hashbatSize = GDKrealloc(tdb->hashbatSize,1+(int)tdb->curFrag* 
sizeof(size_t));
+        assert(tdb->hashbatSize);
         tdb->hashbatSize[frag]        = 0;
         tdb->hashbatSize[new_fragIdx] = 0;
     }

Index: nexi_generate_plan.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/nexi_generate_plan.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- nexi_generate_plan.c        9 Jan 2007 15:44:39 -0000       1.5
+++ nexi_generate_plan.c        24 May 2007 13:10:24 -0000      1.6
@@ -178,8 +178,10 @@
 
   /* initialization for query plan trees */
   p_command_array = calloc(MAX_QUERIES, sizeof(command_tree*));
+  assert(p_command_array);
   p_command_start = p_command_array;
   p_command = calloc(MAX_QUERIES*OPERAND_MAX, sizeof(command_tree));
+  assert(p_command);
 
   /* printf("%d\n",p_command_array); */
   /* printf("%d\n",p_command); */

Index: nexi_generate_mil.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/nexi_generate_mil.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- nexi_generate_mil.c 7 May 2007 07:01:40 -0000       1.28
+++ nexi_generate_mil.c 24 May 2007 13:10:23 -0000      1.29
@@ -207,8 +207,11 @@
 
   /* memory allocation for string manipulation */
   argument1 = calloc(TERM_LENGTH, sizeof(char));
+  assert(argument1);
   term_cut = calloc(TERM_LENGTH, sizeof(char));
+  assert(term_cut);
   unq_term = calloc(ADJ_TERM_MAX * TERM_LENGTH, sizeof(char));
+  assert(unq_term);
 
   /* formating the mil header */
 

Index: pftijah.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/pftijah.mx,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- pftijah.mx  7 May 2007 12:14:43 -0000       1.120
+++ pftijah.mx  24 May 2007 13:10:24 -0000      1.121
@@ -3183,6 +3183,7 @@
 {
        int sz    = strlen(arg);
        char* buf = GDKmalloc(sz + 1);
+       assert(buf);
 
        buf[0] = 0;
        *res = tijah_tokenize_string(arg,sz,buf);
@@ -3195,6 +3196,7 @@
 
        int nDocs = BATcount(doc_loaded);
        BAT **rangeBAT = (BAT**)GDKmalloc(nDocs*sizeof(BAT*));
+       assert(rangeBAT);
        for(int i=0; i<nDocs; i++) {
            rangeBAT[i] = NULL;
         }
@@ -3650,6 +3652,11 @@
        BAT** bats = (BAT**) GDKmalloc(term_cnt * sizeof(BAT*)); 
         BUN* dsts = (BUN*) GDKmalloc(term_cnt * sizeof(BUN));
        int* bfrees = (int*) GDKmalloc(term_cnt * sizeof(int));
+       assert(terms);
+       assert(facs);
+       assert(bats);
+       assert(dsts);
+       assert(bfrees);
        
        /* --------------------------- checks 
---------------------------------- */
        


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to