Ignore:
Timestamp:
Apr 27, 2016, 5:35:59 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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
Message:

modified vector_test to use constructors and destructors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/vector_int.c

    r21ae786 r1ad1c99  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Apr 06 17:18:31 2016
     12// Last Modified On : Wed Apr 27 17:27:12 2016
    1313// Update Count     : 3
    1414//
     
    3030        vec->capacity = reserve;
    3131        vec->data = malloc( sizeof( int ) * reserve );
     32}
     33
     34void ?{}( 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        }
    3241}
    3342
     
    5463// implement bounded_array
    5564
    56 lvalue int ?[?]( vector_int vec, int index ) {
    57         return vec.data[ index ];
     65lvalue int ?[?]( vector_int * vec, int index ) {
     66        return vec->data[ index ];
    5867}
    5968
    60 int last( vector_int vec ) {
    61         return vec.last;
     69int last( vector_int * vec ) {
     70        return vec->last;
    6271}
    6372
Note: See TracChangeset for help on using the changeset viewer.