all repos — mgba @ f62c068a2c59ca2750b6589e1983844c37137c01

mGBA Game Boy Advance Emulator

Util: Add Vector append
Jeffrey Pfau jeffrey@endrift.com
Wed, 04 Feb 2015 02:34:59 -0800
commit

f62c068a2c59ca2750b6589e1983844c37137c01

parent

09cd56820f9445fc9d9f5cefe3a56408b4d654ab

1 files changed, 5 insertions(+), 0 deletions(-)

jump to
M src/util/vector.hsrc/util/vector.h

@@ -17,6 +17,7 @@ }; \

void NAME ## Init(struct NAME* vector, size_t capacity); \ void NAME ## Deinit(struct NAME* vector); \ TYPE* NAME ## GetPointer(struct NAME* vector, size_t location); \ + TYPE* NAME ## Append(struct NAME* vector); \ void NAME ## Resize(struct NAME* vector, ssize_t change); \ void NAME ## Shift(struct NAME* vector, size_t location, size_t difference); \ void NAME ## Unshift(struct NAME* vector, size_t location, size_t difference); \

@@ -39,6 +40,10 @@ vector->capacity = 0; \

} \ TYPE* NAME ## GetPointer(struct NAME* vector, size_t location) { \ return &vector->vector[location]; \ + } \ + TYPE* NAME ## Append(struct NAME* vector) { \ + NAME ## Resize(vector, 1); \ + return &vector->vector[vector->size - 1]; \ } \ void NAME ## Resize(struct NAME* vector, ssize_t change) { \ if (change > 0) { \