Ignore:
Timestamp:
Aug 31, 2021, 1:49:09 AM (10 months ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
enum, forall-pointer-decay, jacob/cs343-translation, master
Children:
52c6891
Parents:
ad8072c
git-author:
Jacob Prud'homme <jafprudhomme@…> (07/23/21 16:27:55)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:09)
Message:

Switched to allocating KVPairs on heap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    rad8072c re74ba77  
    2727        * [ char *, char * ] data;
    2828};
    29 void ?{}( KVPairs & kvp ) with ( kvp ) {        // default constructor
     29void ?{}( KVPairs & kvp ) with ( kvp ) {                                // default constructor
    3030        size = 0; max_size = 0; data = 0p;
    3131}
    32 void ?{}( KVPairs & kvp, int size ) {           // initialization
     32void ?{}( KVPairs & kvp, int size ) {                                   // initialization
    3333        kvp.[ size, max_size ] = [ 0, size ];
    3434        kvp.data = alloc( size );
    3535}
    36 void ^?{}( KVPairs & kvp ) with ( kvp ) {       // destructor
     36/*
     37void ?{}( KVPairs & kvp, KVPairs val ) with( val ) {    // copy, deep
     38        kvp.[ size, max_size ] = [ size, max_size ];
     39        kvp.data = alloc( size, data );
     40}
     41*/
     42void ^?{}( KVPairs & kvp ) with ( kvp ) {                               // destructor
    3743        free( data );
    3844        size = 0; max_size = 0; data = 0p;
     
    6167// Parse configuration from a file formatted in shell style
    6268KVPairs & parse_shell_config_format( const char * config_file, size_t num_entries ) {
    63         KVPairs kv_pairs = { num_entries };
     69        * KVPairs kv_pairs;// = { num_entries };
    6470
    6571        ifstream in;
     
    7480                        in | value;
    7581
    76                         add_kv_pair( kv_pairs, key, value );
     82                        add_kv_pair( *kv_pairs, key, value );
    7783
    7884                  if ( fail( in ) ) break;
     
    8490        close( in );
    8591
    86         return kv_pairs;
     92        return *kv_pairs;
    8793}
    8894
Note: See TracChangeset for help on using the changeset viewer.