changeset 19:740df4b46535 Univ_dev

new branch -- for universal -- changed malloc and free -- do PR__start before use
author Sean Halle <seanhalle@yahoo.com>
date Tue, 23 Jul 2013 07:20:05 -0700
parents ac9b77d9d58b
children 756969c89fe7
files ParamBag.c ReadParamsFromFile.c __brch__Univ_dev __brch__pure_C
diffstat 4 files changed, 20 insertions(+), 18 deletions(-) [+]
line diff
     1.1 --- a/ParamBag.c	Wed Jun 12 15:51:30 2013 -0700
     1.2 +++ b/ParamBag.c	Tue Jul 23 07:20:05 2013 -0700
     1.3 @@ -14,6 +14,7 @@
     1.4  #include <stdlib.h>
     1.5  
     1.6  #include "Param.h"
     1.7 +#include "PR__common_includes/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h"
     1.8  
     1.9  void         freeParamStruc( ParamStruc * param );
    1.10  void         freeParamBagHashEntry( ParamBagHashEntry *entry );
    1.11 @@ -25,8 +26,8 @@
    1.12   ParamBag *
    1.13  makeParamBag()
    1.14   { ParamBag * retBag;
    1.15 -   retBag = malloc( sizeof( ParamBag ) );
    1.16 -   retBag->entries = malloc( PARAM_BAG_HASHSIZE * sizeof( ParamBagHashEntry *) );
    1.17 +   retBag = PR__malloc( sizeof( ParamBag ) );
    1.18 +   retBag->entries = PR__malloc( PARAM_BAG_HASHSIZE * sizeof( ParamBagHashEntry *) );
    1.19     retBag->bagSz = PARAM_BAG_HASHSIZE;
    1.20     nullOutParamBagHashEntries( retBag );
    1.21     
    1.22 @@ -81,7 +82,7 @@
    1.23     hashEntry = lookupKeyInHash( key, bag );
    1.24     if( hashEntry == NULL )
    1.25      { hashIdx = hashKey( key, bag->bagSz );
    1.26 -      hashEntry = (ParamBagHashEntry*) malloc( sizeof( ParamBagHashEntry ) );
    1.27 +      hashEntry = (ParamBagHashEntry*) PR__malloc( sizeof( ParamBagHashEntry ) );
    1.28              if( hashEntry == NULL )  return 0;
    1.29        hashEntry->key = strdup( key );
    1.30              if( hashEntry->key == NULL ) return 0;
    1.31 @@ -119,20 +120,20 @@
    1.32  freeParamBagHashEntry( ParamBagHashEntry *entry )
    1.33   {
    1.34     freeParamStruc( entry->param );
    1.35 -   free( entry->key ); //was malloc'd above, so free it
    1.36 -   free( entry );
    1.37 +   PR__free( entry->key ); //was malloc'd above, so free it
    1.38 +   PR__free( entry );
    1.39   }
    1.40  
    1.41   void
    1.42  freeParamStruc( ParamStruc * param )
    1.43 - { if( param->type == STRING_PARAM_TYPE ) free( param->strValue );
    1.44 -   free( param );
    1.45 + { if( param->type == STRING_PARAM_TYPE ) PR__free( param->strValue );
    1.46 +   PR__free( param );
    1.47   }
    1.48  
    1.49   ParamStruc *
    1.50  makeParamStruc()
    1.51   { ParamStruc *retStruc;
    1.52 -   retStruc = malloc( sizeof( ParamStruc ) );
    1.53 +   retStruc = PR__malloc( sizeof( ParamStruc ) );
    1.54     retStruc->floatValue = 0.0;
    1.55     retStruc->intValue   = 0;
    1.56     retStruc->strValue   = NULL;
    1.57 @@ -165,7 +166,7 @@
    1.58         } break;
    1.59        case 's':
    1.60         { retParam->type = STRING_PARAM_TYPE;
    1.61 -         retParam->strValue = malloc( strlen(value) + 1);
    1.62 +         retParam->strValue = PR__malloc( strlen(value) + 1);
    1.63           strcpy( retParam->strValue, value );
    1.64           removeEndWhtSpaceFromStr( retParam->strValue );
    1.65         } break;
     2.1 --- a/ReadParamsFromFile.c	Wed Jun 12 15:51:30 2013 -0700
     2.2 +++ b/ReadParamsFromFile.c	Tue Jul 23 07:20:05 2013 -0700
     2.3 @@ -9,6 +9,7 @@
     2.4  #include <string.h>
     2.5  
     2.6  #include "Param.h"
     2.7 +#include "PR__common_includes/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h"
     2.8  
     2.9  ParamStruc * makeParamFromStrs( char * type, char *value );
    2.10  
    2.11 @@ -24,7 +25,7 @@
    2.12     if ( lineptr == NULL || n == NULL)  return -1;
    2.13     if (*lineptr == NULL || *n == 0)
    2.14      { *n = 500; //max length of line in a config file
    2.15 -      *lineptr = (char *) malloc( *n );
    2.16 +      *lineptr = (char *) PR__malloc( *n );
    2.17        if (*lineptr == NULL) return -1;
    2.18      }
    2.19     if( fgets( *lineptr, *n, stream ) )
    2.20 @@ -45,7 +46,7 @@
    2.21     char* paramValue;// = malloc( 500 ); //max of 500 chars in value
    2.22     
    2.23     lineSz = 500; //max length of line in a config file
    2.24 -   line = (char *) malloc( lineSz );
    2.25 +   line = (char *) PR__malloc( lineSz );
    2.26     if( line == NULL )
    2.27      { printf( "\nIn readParamFileIntoBag: no mem for line\n" );
    2.28        return;
    2.29 @@ -108,6 +109,6 @@
    2.30            }
    2.31         }
    2.32      }
    2.33 -   free( line );
    2.34 +   PR__free( line );
    2.35   }
    2.36  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/__brch__Univ_dev	Tue Jul 23 07:20:05 2013 -0700
     3.3 @@ -0,0 +1,6 @@
     3.4 +
     3.5 +This branch is for use in pure C code (*not* inside VMS-based language application code)
     3.6 +
     3.7 +There are two versions of the library -- one for pure C use, the other for use inside VMS or within applications written in a VMS-based language (IE, inside a top-level function or a call descendant of a top-level function) -- but only when the VMS is the "MC_shared" version.
     3.8 +
     3.9 +The reason is that VMS that uses shared memory on multicores moves the SlaveVPs around among cores.  But, the libC and glibC malloc stores info at the top of the stack (a "clever" hack), for a speed improvement.  So, when VMS manipulates the stack pointer, and/or moves Slaves to different cores, the "free" seg faults (that was FUN to figure out ; )  So, this version of VMS implements its own malloc. 
    3.10 \ No newline at end of file
     4.1 --- a/__brch__pure_C	Wed Jun 12 15:51:30 2013 -0700
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,6 +0,0 @@
     4.4 -
     4.5 -This branch is for use in pure C code (*not* inside VMS-based language application code)
     4.6 -
     4.7 -There are two versions of the library -- one for pure C use, the other for use inside VMS or within applications written in a VMS-based language (IE, inside a top-level function or a call descendant of a top-level function) -- but only when the VMS is the "MC_shared" version.
     4.8 -
     4.9 -The reason is that VMS that uses shared memory on multicores moves the SlaveVPs around among cores.  But, the libC and glibC malloc stores info at the top of the stack (a "clever" hack), for a speed improvement.  So, when VMS manipulates the stack pointer, and/or moves Slaves to different cores, the "free" seg faults (that was FUN to figure out ; )  So, this version of VMS implements its own malloc. 
    4.10 \ No newline at end of file