changeset 7:1bf28dddc45f MC_shared

Created MC_shared branch
author Me@portablequad
date Sat, 11 Feb 2012 20:08:58 -0800
parents d46150af45ad
children b80587574901
files .brch__MC_shared .hgeol Param.h ParamBag.c ParamBag.h ReadParamsFromFile.c
diffstat 6 files changed, 89 insertions(+), 68 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.brch__MC_shared	Sat Feb 11 20:08:58 2012 -0800
     1.3 @@ -0,0 +1,4 @@
     1.4 +This branch is for the project structure defined Jan 2012..  the #includes reflect this directory structure.
     1.5 +
     1.6 +More importantly, the MC_shared  version of VMS requires a separat malloc implemeted by VMS code..  so this branch has modified the library to use the VMS-specific malloc.
     1.7 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/.hgeol	Sat Feb 11 20:08:58 2012 -0800
     2.3 @@ -0,0 +1,14 @@
     2.4 +
     2.5 +[patterns]
     2.6 +**.py = native
     2.7 +**.txt = native
     2.8 +**.c = native
     2.9 +**.h = native
    2.10 +**.cpp = native
    2.11 +**.java = native
    2.12 +**.class = bin
    2.13 +**.jar = bin
    2.14 +**.sh = native
    2.15 +**.pl = native
    2.16 +**.jpg = bin
    2.17 +**.gif = bin
     3.1 --- a/Param.h	Tue Feb 07 12:51:29 2012 -0800
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,56 +0,0 @@
     3.4 -/* 
     3.5 - * 
     3.6 - * Author: SeanHalle@yahoo.com
     3.7 - *
     3.8 - * Created on November 19, 2009, 6:30 PM
     3.9 - */
    3.10 -
    3.11 -#ifndef _PARAM_H
    3.12 -#define	_PARAM_H
    3.13 -
    3.14 -typedef
    3.15 -struct
    3.16 - { int type;
    3.17 -   int intValue;
    3.18 -   char * strValue;
    3.19 -   float floatValue;
    3.20 - }
    3.21 -ParamStruc;
    3.22 -
    3.23 -#define INT_PARAM_TYPE    0
    3.24 -#define STRING_PARAM_TYPE 1
    3.25 -#define FLOAT_PARAM_TYPE  2
    3.26 -
    3.27 -#define PARAM_BAG_HASHSIZE 1024
    3.28 -
    3.29 -typedef struct _ParamBagHashEntry ParamBagHashEntry;
    3.30 -
    3.31 -struct _ParamBagHashEntry
    3.32 - {
    3.33 -   char       *key;
    3.34 -   ParamStruc *param;
    3.35 -   struct _ParamBagHashEntry *next;
    3.36 - }
    3.37 -/*ParamBagHashEntry*/;
    3.38 -
    3.39 -
    3.40 -typedef
    3.41 -struct
    3.42 - { int bagSz;
    3.43 -   ParamBagHashEntry* *entries;
    3.44 - }
    3.45 -ParamBag;
    3.46 -
    3.47 -
    3.48 -ParamBag    *makeParamBag();
    3.49 -void         readParamFileIntoBag( char *paramFileName, ParamBag * bag );
    3.50 -ParamStruc  *getParamFromBag( char *key, ParamBag * bag );
    3.51 -int          addParamToBag( char* key, ParamStruc *param, ParamBag *bag );
    3.52 -void         freeParamBag( ParamBag *bag );
    3.53 -//char        *paramBagToString( ParamBag * bag );
    3.54 -ParamStruc  *makeParamStruc();
    3.55 -ParamStruc  *makeParamFromStrs( char * type, char *value );
    3.56 -ssize_t      getline( char **lineptr, size_t *n, FILE *stream );
    3.57 -
    3.58 -#endif	/* _PARAM_H */
    3.59 -
     4.1 --- a/ParamBag.c	Tue Feb 07 12:51:29 2012 -0800
     4.2 +++ b/ParamBag.c	Sat Feb 11 20:08:58 2012 -0800
     4.3 @@ -24,8 +24,8 @@
     4.4   ParamBag *
     4.5  makeParamBag()
     4.6   { ParamBag * retBag;
     4.7 -   retBag = malloc( sizeof( ParamBag ) );
     4.8 -   retBag->entries = malloc( PARAM_BAG_HASHSIZE * sizeof( ParamBagHashEntry *) );
     4.9 +   retBag = VMS__malloc( sizeof( ParamBag ) );
    4.10 +   retBag->entries = VMS__malloc( PARAM_BAG_HASHSIZE * sizeof( ParamBagHashEntry *) );
    4.11     retBag->bagSz = PARAM_BAG_HASHSIZE;
    4.12     nullOutParamBagHashEntries( retBag );
    4.13     
    4.14 @@ -80,7 +80,7 @@
    4.15     hashEntry = lookupKeyInHash( key, bag );
    4.16     if( hashEntry == NULL )
    4.17      { hashIdx = hashKey( key, bag->bagSz );
    4.18 -      hashEntry = (ParamBagHashEntry*) malloc( sizeof( ParamBagHashEntry ) );
    4.19 +      hashEntry = (ParamBagHashEntry*) VMS__malloc( sizeof( ParamBagHashEntry ) );
    4.20              if( hashEntry == NULL )  return 0;
    4.21        hashEntry->key = strdup( key );
    4.22              if( hashEntry->key == NULL ) return 0;
    4.23 @@ -118,20 +118,20 @@
    4.24  freeParamBagHashEntry( ParamBagHashEntry *entry )
    4.25   {
    4.26     freeParamStruc( entry->param );
    4.27 -   free( entry->key ); //was malloc'd above, so free it
    4.28 -   free( entry );
    4.29 +   VMS__free( entry->key ); //was malloc'd above, so free it
    4.30 +   VMS__free( entry );
    4.31   }
    4.32  
    4.33   void
    4.34  freeParamStruc( ParamStruc * param )
    4.35 - { if( param->type == STRING_PARAM_TYPE ) free( param->strValue );
    4.36 -   free( param );
    4.37 + { if( param->type == STRING_PARAM_TYPE ) VMS__free( param->strValue );
    4.38 +   VMS__free( param );
    4.39   }
    4.40  
    4.41   ParamStruc *
    4.42  makeParamStruc()
    4.43   { ParamStruc *retStruc;
    4.44 -   retStruc = malloc( sizeof( ParamStruc ) );
    4.45 +   retStruc = VMS__malloc( sizeof( ParamStruc ) );
    4.46     retStruc->floatValue = 0.0;
    4.47     retStruc->intValue   = 0;
    4.48     retStruc->strValue   = NULL;
    4.49 @@ -164,7 +164,7 @@
    4.50         } break;
    4.51        case 's':
    4.52         { retParam->type = STRING_PARAM_TYPE;
    4.53 -         retParam->strValue = malloc( strlen(value) + 1);
    4.54 +         retParam->strValue = VMS__malloc( strlen(value) + 1);
    4.55           strcpy( retParam->strValue, value );
    4.56           removeEndWhtSpaceFromStr( retParam->strValue );
    4.57         } break;
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/ParamBag.h	Sat Feb 11 20:08:58 2012 -0800
     5.3 @@ -0,0 +1,59 @@
     5.4 +/* 
     5.5 + * 
     5.6 + * Author: SeanHalle@yahoo.com
     5.7 + *
     5.8 + * Created on November 19, 2009, 6:30 PM
     5.9 + */
    5.10 +
    5.11 +#ifndef _PARAM_H
    5.12 +#define	_PARAM_H
    5.13 +
    5.14 +#include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h"
    5.15 +#include "../../VMS_Implementations/VMS_impl/vmalloc.h"
    5.16 +
    5.17 +typedef
    5.18 +struct
    5.19 + { int type;
    5.20 +   int intValue;
    5.21 +   char * strValue;
    5.22 +   float floatValue;
    5.23 + }
    5.24 +ParamStruc;
    5.25 +
    5.26 +#define INT_PARAM_TYPE    0
    5.27 +#define STRING_PARAM_TYPE 1
    5.28 +#define FLOAT_PARAM_TYPE  2
    5.29 +
    5.30 +#define PARAM_BAG_HASHSIZE 1024
    5.31 +
    5.32 +typedef struct _ParamBagHashEntry ParamBagHashEntry;
    5.33 +
    5.34 +struct _ParamBagHashEntry
    5.35 + {
    5.36 +   char       *key;
    5.37 +   ParamStruc *param;
    5.38 +   struct _ParamBagHashEntry *next;
    5.39 + }
    5.40 +/*ParamBagHashEntry*/;
    5.41 +
    5.42 +
    5.43 +typedef
    5.44 +struct
    5.45 + { int bagSz;
    5.46 +   ParamBagHashEntry* *entries;
    5.47 + }
    5.48 +ParamBag;
    5.49 +
    5.50 +
    5.51 +ParamBag    *makeParamBag();
    5.52 +void         readParamFileIntoBag( char *paramFileName, ParamBag * bag );
    5.53 +ParamStruc  *getParamFromBag( char *key, ParamBag * bag );
    5.54 +int          addParamToBag( char* key, ParamStruc *param, ParamBag *bag );
    5.55 +void         freeParamBag( ParamBag *bag );
    5.56 +//char        *paramBagToString( ParamBag * bag );
    5.57 +ParamStruc  *makeParamStruc();
    5.58 +ParamStruc  *makeParamFromStrs( char * type, char *value );
    5.59 +ssize_t      getline( char **lineptr, size_t *n, FILE *stream );
    5.60 +
    5.61 +#endif	/* _PARAM_H */
    5.62 +
     6.1 --- a/ReadParamsFromFile.c	Tue Feb 07 12:51:29 2012 -0800
     6.2 +++ b/ReadParamsFromFile.c	Sat Feb 11 20:08:58 2012 -0800
     6.3 @@ -22,7 +22,7 @@
     6.4     if ( lineptr == NULL || n == NULL)  return -1;
     6.5     if (*lineptr == NULL || *n == 0)
     6.6      { *n = 500; //max length of line in a config file
     6.7 -      *lineptr = (char *) malloc( *n );
     6.8 +      *lineptr = (char *) VMS__malloc( *n );
     6.9        if (*lineptr == NULL) return -1;
    6.10      }
    6.11     if( fgets( *lineptr, *n, stream ) )
    6.12 @@ -43,7 +43,7 @@
    6.13     char* paramValue;// = malloc( 500 ); //max of 500 chars in value
    6.14     
    6.15     lineSz = 500; //max length of line in a config file
    6.16 -   line = (char *) malloc( lineSz );
    6.17 +   line = (char *) VMS__malloc( lineSz );
    6.18     if( line == NULL )
    6.19      { printf( "\nIn readParamFileIntoBag: no mem for line\n" );
    6.20        return;
    6.21 @@ -106,6 +106,6 @@
    6.22            }
    6.23         }
    6.24      }
    6.25 -   free( line );
    6.26 +   VMS__free( line );
    6.27   }
    6.28