Changeset 2afec66 for src/tests/vector/vector_int.c
- Timestamp:
- Jul 26, 2017, 5:24:33 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 25bd9074
- Parents:
- 8a6cf7e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/vector/vector_int.c
r8a6cf7e r2afec66 20 20 #define DEFAULT_CAPACITY 20 21 21 22 void ?{}( vector_int *vec ) {22 void ?{}( vector_int & vec ) { 23 23 vec { DEFAULT_CAPACITY }; 24 24 } 25 25 26 void ?{}( vector_int *vec, int reserve ) {27 vec ->last = -1;28 vec ->capacity = reserve;29 vec ->data = malloc( sizeof( int ) * reserve );26 void ?{}( vector_int & vec, int reserve ) { 27 vec.last = -1; 28 vec.capacity = reserve; 29 vec.data = malloc( sizeof( int ) * reserve ); 30 30 } 31 31 32 void ?{}( vector_int *vec, vector_int other ) {33 vec ->last = other.last;34 vec ->capacity = other.capacity;35 vec ->data = malloc( sizeof( int ) * other.capacity );36 for (int i = 0; i < vec ->last; i++) {37 vec ->data[i] = other.data[i];32 void ?{}( vector_int & vec, vector_int other ) { 33 vec.last = other.last; 34 vec.capacity = other.capacity; 35 vec.data = malloc( sizeof( int ) * other.capacity ); 36 for (int i = 0; i < vec.last; i++) { 37 vec.data[i] = other.data[i]; 38 38 } 39 39 } 40 40 41 void ^?{}( vector_int *vec ) {41 void ^?{}( vector_int & vec ) { 42 42 free( vec->data ); 43 43 }
Note: See TracChangeset
for help on using the changeset viewer.