# HG changeset patch # User Sean Halle # Date 1374589205 25200 # Node ID 740df4b465357a7c0bbd2e2979a189f6b8c658f1 # Parent ac9b77d9d58b9630ed1904c312349720b0302ea5 new branch -- for universal -- changed malloc and free -- do PR__start before use diff -r ac9b77d9d58b -r 740df4b46535 ParamBag.c --- a/ParamBag.c Wed Jun 12 15:51:30 2013 -0700 +++ b/ParamBag.c Tue Jul 23 07:20:05 2013 -0700 @@ -14,6 +14,7 @@ #include #include "Param.h" +#include "PR__common_includes/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h" void freeParamStruc( ParamStruc * param ); void freeParamBagHashEntry( ParamBagHashEntry *entry ); @@ -25,8 +26,8 @@ ParamBag * makeParamBag() { ParamBag * retBag; - retBag = malloc( sizeof( ParamBag ) ); - retBag->entries = malloc( PARAM_BAG_HASHSIZE * sizeof( ParamBagHashEntry *) ); + retBag = PR__malloc( sizeof( ParamBag ) ); + retBag->entries = PR__malloc( PARAM_BAG_HASHSIZE * sizeof( ParamBagHashEntry *) ); retBag->bagSz = PARAM_BAG_HASHSIZE; nullOutParamBagHashEntries( retBag ); @@ -81,7 +82,7 @@ hashEntry = lookupKeyInHash( key, bag ); if( hashEntry == NULL ) { hashIdx = hashKey( key, bag->bagSz ); - hashEntry = (ParamBagHashEntry*) malloc( sizeof( ParamBagHashEntry ) ); + hashEntry = (ParamBagHashEntry*) PR__malloc( sizeof( ParamBagHashEntry ) ); if( hashEntry == NULL ) return 0; hashEntry->key = strdup( key ); if( hashEntry->key == NULL ) return 0; @@ -119,20 +120,20 @@ freeParamBagHashEntry( ParamBagHashEntry *entry ) { freeParamStruc( entry->param ); - free( entry->key ); //was malloc'd above, so free it - free( entry ); + PR__free( entry->key ); //was malloc'd above, so free it + PR__free( entry ); } void freeParamStruc( ParamStruc * param ) - { if( param->type == STRING_PARAM_TYPE ) free( param->strValue ); - free( param ); + { if( param->type == STRING_PARAM_TYPE ) PR__free( param->strValue ); + PR__free( param ); } ParamStruc * makeParamStruc() { ParamStruc *retStruc; - retStruc = malloc( sizeof( ParamStruc ) ); + retStruc = PR__malloc( sizeof( ParamStruc ) ); retStruc->floatValue = 0.0; retStruc->intValue = 0; retStruc->strValue = NULL; @@ -165,7 +166,7 @@ } break; case 's': { retParam->type = STRING_PARAM_TYPE; - retParam->strValue = malloc( strlen(value) + 1); + retParam->strValue = PR__malloc( strlen(value) + 1); strcpy( retParam->strValue, value ); removeEndWhtSpaceFromStr( retParam->strValue ); } break; diff -r ac9b77d9d58b -r 740df4b46535 ReadParamsFromFile.c --- a/ReadParamsFromFile.c Wed Jun 12 15:51:30 2013 -0700 +++ b/ReadParamsFromFile.c Tue Jul 23 07:20:05 2013 -0700 @@ -9,6 +9,7 @@ #include #include "Param.h" +#include "PR__common_includes/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h" ParamStruc * makeParamFromStrs( char * type, char *value ); @@ -24,7 +25,7 @@ if ( lineptr == NULL || n == NULL) return -1; if (*lineptr == NULL || *n == 0) { *n = 500; //max length of line in a config file - *lineptr = (char *) malloc( *n ); + *lineptr = (char *) PR__malloc( *n ); if (*lineptr == NULL) return -1; } if( fgets( *lineptr, *n, stream ) ) @@ -45,7 +46,7 @@ char* paramValue;// = malloc( 500 ); //max of 500 chars in value lineSz = 500; //max length of line in a config file - line = (char *) malloc( lineSz ); + line = (char *) PR__malloc( lineSz ); if( line == NULL ) { printf( "\nIn readParamFileIntoBag: no mem for line\n" ); return; @@ -108,6 +109,6 @@ } } } - free( line ); + PR__free( line ); } diff -r ac9b77d9d58b -r 740df4b46535 __brch__Univ_dev --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/__brch__Univ_dev Tue Jul 23 07:20:05 2013 -0700 @@ -0,0 +1,6 @@ + +This branch is for use in pure C code (*not* inside VMS-based language application code) + +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. + +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. \ No newline at end of file diff -r ac9b77d9d58b -r 740df4b46535 __brch__pure_C --- a/__brch__pure_C Wed Jun 12 15:51:30 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ - -This branch is for use in pure C code (*not* inside VMS-based language application code) - -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. - -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. \ No newline at end of file