Changes in src/examples/vector_int.c [eab39cd:86bd7c1f]
- File:
-
- 1 edited
-
src/examples/vector_int.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/vector_int.c
reab39cd r86bd7c1f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // vector_int.c -- 7 // vector_int.c -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 06 17:18:31 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:38:05 2015 13 13 // Update Count : 3 14 14 // … … 22 22 #define DEFAULT_CAPACITY 20 23 23 24 v oid ?{}( vector_int * vec) {25 vec { DEFAULT_CAPACITY };24 vector_int vector_int_allocate() { 25 return vector_int_allocate( DEFAULT_CAPACITY ); 26 26 } 27 27 28 void ?{}( vector_int * vec, int reserve ) { 29 vec->last = -1; 30 vec->capacity = reserve; 31 vec->data = malloc( sizeof( int ) * reserve ); 28 vector_int vector_int_allocate( int reserve ) { 29 vector_int new_vector; 30 new_vector.last = -1; 31 new_vector.capacity = reserve; 32 new_vector.data = malloc( sizeof( int ) * reserve ); 33 return new_vector; 32 34 } 33 35 34 void ^?{}( vector_int *vec ) {35 free( vec ->data );36 void vector_int_deallocate( vector_int vec ) { 37 free( vec.data ); 36 38 } 37 39
Note:
See TracChangeset
for help on using the changeset viewer.