diff options
Diffstat (limited to 'typeutils.h')
| -rw-r--r-- | typeutils.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/typeutils.h b/typeutils.h index fd285b2..d83217d 100644 --- a/typeutils.h +++ b/typeutils.h @@ -23,7 +23,7 @@ .incr_step = step, \ }; \ } \ - static inline void push_to_##Name(Name* vec, T item) { \ + static inline T* push_to_##Name(Name* vec, T item) { \ if (vec->count == vec->cap) { \ vec->cap += vec->incr_step; \ vec->items = realloc( \ @@ -31,7 +31,10 @@ vec->cap * sizeof(T) \ ); \ } \ - vec->items[vec->count++] = item; \ + vec->items[vec->count] = item; \ + T* ptr = &vec->items[vec->count]; \ + vec->count++; \ + return ptr; \ } |
