Update of /cvsroot/monetdb/pathfinder/compiler/mem
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19324/mem

Modified Files:
        array.c bitset.c mem.c mem_gc.c 
Log Message:
-- The endless Odyssey through the pathfinder code checking
   for correct initialization of global variables (Part 2).

   This time---checking all files in folders:
    o compiler/mem
    o compiler/schema
    o compiler/utils


U mem.c
Index: mem.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mem/mem.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- mem.c       11 Jan 2008 10:47:10 -0000      1.23
+++ mem.c       2 Apr 2008 16:35:44 -0000       1.24
@@ -2,7 +2,7 @@
 
 /**
  * @file mem.c
- * Garbage collected memory and string allocation 
+ * Garbage collected memory and string allocation
  * (@a no allocation of specific objects [parse tree nodes, etc.] here!)
  *
  *
@@ -48,12 +48,12 @@
     size_t size;
     size_t nr;
     char **blks;
-    size_t used;       /* memory used in last block */
+    size_t used;        /* memory used in last block */
 } PFmem_allocator;
 
 #define SA_BLOCK (4*1024*1024)
 
-PFmem_allocator *pf_alloc = NULL;
+static PFmem_allocator *pf_alloc = NULL;
 
 void
 PFmem_init(void)
@@ -61,7 +61,7 @@
     assert (!pf_alloc);
 
     pf_alloc = (PFmem_allocator*)malloc(sizeof(PFmem_allocator));
-    
+
     pf_alloc->size = 64;
     pf_alloc->nr = 1;
     pf_alloc->blks = (char**)malloc(pf_alloc->size*sizeof(char*));
@@ -129,7 +129,7 @@
 }
 
 char *
-mem_realloc (PFmem_allocator *pa, char *p, size_t old_n, size_t n) 
+mem_realloc (PFmem_allocator *pa, char *p, size_t old_n, size_t n)
 {
         char *r = mem_alloc( pa, n);
         size_t i;
@@ -141,7 +141,7 @@
  * Worker for #PFmalloc ().
  */
 void *
-PFmalloc_ (size_t n, const char *file, const char *func, const int line) 
+PFmalloc_ (size_t n, const char *file, const char *func, const int line)
 {
     void *mem;
     /* allocate garbage collected heap memory of requested size */
@@ -149,7 +149,7 @@
 
     if (mem == 0) {
         /* don't use PFoops () here as it tries to allocate even more memory */
-        PFlog ("fatal error: insufficient memory (allocating "SZFMT" bytes 
failed) in %s (%s), line %d", 
+        PFlog ("fatal error: insufficient memory (allocating "SZFMT" bytes 
failed) in %s (%s), line %d",
                 n, file, func, line);
         PFexit(-OOPS_FATAL);
     }
@@ -162,14 +162,14 @@
  */
 void *
 PFrealloc_ (void *mem, size_t old_n, size_t n,
-           const char *file, const char *func, const int line) 
+            const char *file, const char *func, const int line)
 {
     /* resize garbage collected heap memory to requested size */
     mem = mem_realloc (pf_alloc, mem, old_n, n);
 
     if (mem == 0) {
         /* don't use PFoops () here as it tries to allocate even more memory */
-        PFlog ("fatal error: insufficient memory (re-allocating "SZFMT" bytes 
failed) in %s (%s), line %d", 
+        PFlog ("fatal error: insufficient memory (re-allocating "SZFMT" bytes 
failed) in %s (%s), line %d",
                 n, file, func, line);
         PFexit(-OOPS_FATAL);
     }
@@ -179,7 +179,7 @@
 
 /**
  * Allocates enough memory to hold a copy of @a str
- * and return a pointer to this copy 
+ * and return a pointer to this copy
  * If you specify @a n != 0, the copy will hold @a n characters (+ the
  * trailing '\\0') only.
  * @param str string to copy
@@ -214,5 +214,4 @@
     return PFstrndup (str, strlen (str));
 }
 
-
 /* vim:set shiftwidth=4 expandtab: */

U mem_gc.c
Index: mem_gc.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mem/mem_gc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mem_gc.c    11 Jan 2008 10:47:10 -0000      1.5
+++ mem_gc.c    2 Apr 2008 16:35:44 -0000       1.6
@@ -2,7 +2,7 @@
 
 /**
  * @file mem.c
- * Garbage collected memory and string allocation 
+ * Garbage collected memory and string allocation
  * (@a no allocation of specific objects [parse tree nodes, etc.] here!)
  *
  *
@@ -35,12 +35,12 @@
 #include "pathfinder.h"
 
 #if !HAVE_GC
-/* we need a fallback solution in case 
+/* we need a fallback solution in case
    we have no garbage collector */
 #include "mem.c"
 
 #else
-/* we have a garbage collector 
+/* we have a garbage collector
    (thus use it to implement the memory interface) */
 
 #include <string.h>
@@ -66,7 +66,7 @@
  * Worker for #PFmalloc ().
  */
 void *
-PFmalloc_ (size_t n, const char *file, const char *func, const int line) 
+PFmalloc_ (size_t n, const char *file, const char *func, const int line)
 {
     void *mem;
     /* allocate garbage collected heap memory of requested size */
@@ -74,7 +74,7 @@
 
     if (mem == 0) {
         /* don't use PFoops () here as it tries to allocate even more memory */
-        PFlog ("fatal error: insufficient memory (allocating "SZFMT" bytes 
failed) in %s (%s), line %d", 
+        PFlog ("fatal error: insufficient memory (allocating "SZFMT" bytes 
failed) in %s (%s), line %d",
                 n, file, func, line);
         PFexit(-OOPS_FATAL);
     }
@@ -87,7 +87,7 @@
  */
 void *
 PFrealloc_ (void *mem, size_t old_n, size_t n,
-           const char *file, const char *func, const int line) 
+            const char *file, const char *func, const int line)
 {
     (void) old_n;
     /* resize garbage collected heap memory to requested size */
@@ -95,7 +95,7 @@
 
     if (mem == 0) {
         /* don't use PFoops () here as it tries to allocate even more memory */
-        PFlog ("fatal error: insufficient memory (re-allocating "SZFMT" bytes 
failed) in %s (%s), line %d", 
+        PFlog ("fatal error: insufficient memory (re-allocating "SZFMT" bytes 
failed) in %s (%s), line %d",
                 n, file, func, line);
         PFexit(-OOPS_FATAL);
     }
@@ -105,7 +105,7 @@
 
 /**
  * Allocates enough memory to hold a copy of @a str
- * and return a pointer to this copy 
+ * and return a pointer to this copy
  * If you specify @a n != 0, the copy will hold @a n characters (+ the
  * trailing '\\0') only.
  * @param str string to copy

U bitset.c
Index: bitset.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mem/bitset.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- bitset.c    17 Mar 2008 17:41:24 -0000      1.7
+++ bitset.c    2 Apr 2008 16:35:43 -0000       1.8
@@ -7,7 +7,7 @@
  *
  * Basic interface:
  * - #PFbitset ()            Create a new bitset, with all values set to false.
- * - #PFbitset_set (a, n, b) Set the n-th bit to the value b. 
+ * - #PFbitset_set (a, n, b) Set the n-th bit to the value b.
  * - #PFbitset_get (a, n)    Get the n-th bit bit.
  *
  * Copyright Notice:
@@ -57,7 +57,7 @@
 #define UNIT_IDX(x) ((x) >> ADDR_BITS_PER_UNIT)
 #define BITSET_UNIT_AT(a, b) (*((bitset_unit *)PFarray_at ((a), (b))))
 
-PFbitset_t *PFbitset (void) 
+PFbitset_t *PFbitset (void)
 {
     return PFarray (sizeof (bitset_unit), 128 /* start with 1024 bits */);
 }
@@ -68,7 +68,7 @@
     unsigned int unit_pos = UNIT_IDX (pos);
 
     if (unit_pos >= size)
-        PFarray_nadd (b, unit_pos - size + 1); 
+        PFarray_nadd (b, unit_pos - size + 1);
 
     /* Initialize new allocated part of array */
     for (unsigned int i = size; i <= unit_pos; i++)
@@ -80,7 +80,7 @@
         BITSET_UNIT_AT (b, unit_pos) &= ~BIT (pos);
 }
 
-bool PFbitset_get (PFbitset_t *b, unsigned int pos) 
+bool PFbitset_get (PFbitset_t *b, unsigned int pos)
 {
     unsigned int size = PFarray_last (b);
     unsigned int unit_pos = UNIT_IDX (pos);
@@ -98,7 +98,7 @@
     unsigned int base_size = PFarray_last (base);
     if (ext_size > base_size)
         /* ensure capacity */
-        PFarray_nadd (base, ext_size - base_size); 
+        PFarray_nadd (base, ext_size - base_size);
     for (unsigned int i = 0; i < ext_size; i++)
         BITSET_UNIT_AT (base, i) |= BITSET_UNIT_AT (ext, i);
 }

U array.c
Index: array.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mem/array.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- array.c     19 Mar 2008 13:30:49 -0000      1.29
+++ array.c     2 Apr 2008 16:35:43 -0000       1.30
@@ -12,7 +12,7 @@
  * - #PFarray_at (a, i) address of ith element in array a (a grows as needed)
  * - #PFarray_last (a)  ``append index'': where to append to this array (r/w)
  *
- * More complex operations may be constructed using 
+ * More complex operations may be constructed using
  * the basic interface, e.g.,
  * - append one element e to array a (available as #PFarray_add):
  *   @code
@@ -69,16 +69,16 @@
 #include "mem.h"
 #include "oops.h"
 
-/** 
+/**
  * size (in bytes) rounded up to whenever a fresh array is allocated or
- * an out-of-bounds index has been accessed 
+ * an out-of-bounds index has been accessed
  */
 #define ACHUNK 8U
 
 #ifndef NDEBUG
 /* switch to turn debug printing
    of memory reallocations on/off */
-bool debug_memory; 
+bool debug_memory;
 #endif
 
 /**
@@ -116,20 +116,20 @@
 
 /**
  * Compute the address of element position @c i of array @c a (if @c i
- * is an out-of-bounds index, grow @a as needed). 
+ * is an out-of-bounds index, grow @a as needed).
  *
  * @param a array
  * @param i array index
  * @return array element address (or 0, in case of errors)
  */
-void * 
+void *
 #ifndef NDEBUG
 PFarray_at_ (PFarray_t *a, unsigned int i,
-             const char *file, const char *func, const int line) 
+             const char *file, const char *func, const int line)
 #else
 PFarray_at (PFarray_t *a, unsigned int i)
 #endif
-{ 
+{
   size_t nbytes;
 
   assert (a);
@@ -149,8 +149,8 @@
 #endif
 
       if (i > 2 * a->bound)
-          /* out-of-bounds index access, 
-           * grow array such that index position i becomes valid 
+          /* out-of-bounds index access,
+           * grow array such that index position i becomes valid
            */
           nbytes = ((i + 1) * a->esize + ACHUNK) & (~ACHUNK + 1);
       else
@@ -273,7 +273,7 @@
      */
     (void) vsnprintf ((char *) PFarray_nadd (a, nchars + 1), nchars + 1, fmt, 
mat);
 
-    
+
     /* overwrite trailing '\0' on next print to this array */
     PFarray_last (a)--;
 
@@ -282,8 +282,8 @@
 }
 
 /**
- * Array concatenation.  The entries of a2 are inserted 
- * into a1 (at end).  
+ * Array concatenation.  The entries of a2 are inserted
+ * into a1 (at end).
  *
  * @attention NB. this makes sense only if both arrays have entries of
  *   the same size.
@@ -313,7 +313,7 @@
 
 /**
  * Array copy.  The entries of input are inserted
- * into a new array output.  
+ * into a new array output.
  *
  * @param input input array (unchanged)
  * @return array @a output with a copy of the entries of @a input


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to