Changeset f789b82


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:
1e05e09
Parents:
cfadd08
git-author:
Jacob Prud'homme <jafprudhomme@…> (08/03/21 01:19:09)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:10)
Message:

Removed old string builder code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    rcfadd08 rf789b82  
    5252
    5353        data[size] = [ k, v ];
    54         ++size;
    55 }
    56 
    57 
    58 struct StringBuilder {
    59         int size, max_size;
    60         * char string;
    61 };
    62 void ?{}( StringBuilder & sb ) with ( sb ) {                            // default constructor
    63         size = 1; max_size = 1; string = alloc( 1 );
    64         string[0] = '\0';
    65 }
    66 void ?{}( StringBuilder & sb, int size ) {                                      // initialization
    67         sb.[ size, max_size ] = [ 1, size+1 ];
    68         sb.string = alloc( size );
    69         sb.string[0] = '\0';
    70 }
    71 void ^?{}( StringBuilder & sb ) with ( sb ) {                           // destructor
    72         free( string );
    73         size = 0; max_size = 0; string = 0p;
    74 }
    75 
    76 void add_char( StringBuilder & sb, char c ) with ( sb ) {
    77         if ( size == max_size ) {
    78                 max_size *= 2;
    79                 string = resize( string, max_size );
    80         }
    81 
    82         string[size-1] = c;
    83         string[size] = '\0';
    8454        ++size;
    8555}
Note: See TracChangeset for help on using the changeset viewer.