Ignore:
Timestamp:
Jul 12, 2017, 4:40:02 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
0698aa1
Parents:
469f709
Message:

Convert several library files to use references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/vector.c

    r469f709 raca65621  
    2424//Initialization
    2525forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    26 void ?{}(vector(T, allocator_t)* this)
     26void ?{}(vector(T, allocator_t)& this)
    2727{
    28         (&this->storage){};
    29         this->size = 0;
     28        (this.storage){};
     29        this.size = 0;
    3030}
    3131
    3232forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    33 void ?{}(vector(T, allocator_t)* this, vector(T, allocator_t) rhs)
     33void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs)
    3434{
    35         (&this->storage){ rhs.storage };
    36         copy_internal(this, &rhs);
     35        (this.storage){ rhs.storage };
     36        copy_internal(&this, &rhs);
    3737}
    3838
     
    4646
    4747forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    48 void ^?{}(vector(T, allocator_t)* this)
     48void ^?{}(vector(T, allocator_t)& this)
    4949{
    50         clear(this);
    51         ^(&this->storage){};
     50        clear(&this);
     51        ^(this.storage){};
    5252}
    5353
     
    6666{
    6767        this->size--;
    68         ^(&data(&this->storage)[this->size]){};
     68        ^(data(&this->storage)[this->size]){};
    6969}
    7070
     
    7474        for(size_t i = 0; i < this->size; i++)
    7575        {
    76                 ^(&data(&this->storage)[this->size]){};
     76                ^(data(&this->storage)[this->size]){};
    7777        }
    7878        this->size = 0;
     
    8787        this->size = other->size;
    8888        for(size_t i = 0; i < this->size; i++) {
    89                 (&data(&this->storage)[this->size]){ data(&other->storage)[other->size] };
     89                (data(&this->storage)[this->size]){ data(&other->storage)[other->size] };
    9090        }
    9191}
     
    9494//Allocator
    9595forall(otype T)
    96 void ?{}(heap_allocator(T)* this)
     96void ?{}(heap_allocator(T)& this)
    9797{
    98         this->storage = 0;
    99         this->capacity = 0;
     98        this.storage = 0;
     99        this.capacity = 0;
    100100}
    101101
    102102forall(otype T)
    103 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs)
     103void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs)
    104104{
    105         this->capacity = rhs.capacity;
    106         this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));
     105        this.capacity = rhs.capacity;
     106        this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T));
    107107}
    108108
    109109forall(otype T)
    110 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs)
     110heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs)
    111111{
    112         this->capacity = rhs.capacity;
    113         this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));
    114         return *this;
     112        this.capacity = rhs.capacity;
     113        this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T));
     114        return this;
    115115}
    116116
    117117forall(otype T)
    118 void ^?{}(heap_allocator(T)* this)
     118void ^?{}(heap_allocator(T)& this)
    119119{
    120         free(this->storage);
     120        free(this.storage);
    121121}
    122122
Note: See TracChangeset for help on using the changeset viewer.