Changeset e4b37a1 for libcfa/src


Ignore:
Timestamp:
Aug 31, 2021, 1:49:10 AM (3 years ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
Children:
ad78e08
Parents:
12b5b226
git-author:
Jacob Prud'homme <jafprudhomme@…> (08/03/21 13:23:35)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:10)
Message:

Switched to allocating array of KVPs on heap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r12b5b226 re4b37a1  
    2424
    2525struct KVPairs {
    26         int size, max_size;
     26        unsigned int size, max_size;
    2727        * [ char *, char * ] data;
    2828};
     
    3030        size = 0; max_size = 0; data = 0p;
    3131}
    32 void ?{}( KVPairs & kvp, int size ) {                                   // initialization
     32void ?{}( KVPairs & kvp, size_t size ) {                                // initialization
    3333        kvp.[ size, max_size ] = [ 0, size ];
    3434        kvp.data = alloc( size );
     
    6464// Parse configuration from a file formatted in shell style
    6565KVPairs & parse_tabular_config_format( const char * config_file, size_t num_entries ) {
    66         KVPairs kv_pairs = { num_entries };
     66        * KVPairs kv_pairs = new( num_entries );
    6767
    6868        ifstream in;
     
    7979                        in | value;
    8080
    81                         add_kv_pair( kv_pairs, key, value );
     81                        add_kv_pair( *kv_pairs, key, value );
    8282
    8383                  if ( eof( in ) ) break;
     
    8585                } // for
    8686        } catch( Open_Failure * ex; ex->istream == &in ) {
    87                 ^kv_pairs{};
     87                ^(*kv_pairs){};
    8888                exit | "Error: could not open input file \"" | config_file | "\"";
    8989        } // try
    9090        close( in );
    9191
    92         return kv_pairs;
     92        return *kv_pairs;
    9393}
    9494
    9595// Parse configuration values from intermediate format
    9696void parse_config( const char * config_file, config_entry entries[], size_t num_entries ) {
    97         KVPairs kv_pairs = parse_tabular_config_format( config_file, num_entries );
     97        KVPairs & kv_pairs = parse_tabular_config_format( config_file, num_entries );
    9898
    9999        int entries_so_far = 0;
Note: See TracChangeset for help on using the changeset viewer.