Changeset 1ad1c99 for src/examples/vector_int.c
- Timestamp:
- Apr 27, 2016, 5:35:59 PM (6 years ago)
- Branches:
- aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
- Children:
- 84bb4d9
- Parents:
- 21ae786
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/vector_int.c
r21ae786 r1ad1c99 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Apr 06 17:18:31201612 // Last Modified On : Wed Apr 27 17:27:12 2016 13 13 // Update Count : 3 14 14 // … … 30 30 vec->capacity = reserve; 31 31 vec->data = malloc( sizeof( int ) * reserve ); 32 } 33 34 void ?{}( vector_int * vec, vector_int other ) { 35 vec->last = other.last; 36 vec->capacity = other.capacity; 37 vec->data = malloc( sizeof( int ) * other.capacity ); 38 for (int i = 0; i < vec->last; i++) { 39 vec->data[i] = other.data[i]; 40 } 32 41 } 33 42 … … 54 63 // implement bounded_array 55 64 56 lvalue int ?[?]( vector_int vec, int index ) {57 return vec .data[ index ];65 lvalue int ?[?]( vector_int * vec, int index ) { 66 return vec->data[ index ]; 58 67 } 59 68 60 int last( vector_int vec ) {61 return vec .last;69 int last( vector_int * vec ) { 70 return vec->last; 62 71 } 63 72
Note: See TracChangeset
for help on using the changeset viewer.