fixed inline functions

master
Dvir Volk 8 years ago
parent c3d0c99023
commit 51f135b30a

@ -79,3 +79,8 @@ void Vector_Free(Vector *v) {
free(v->data); free(v->data);
free(v); free(v);
} }
inline int Vector_Size(Vector *v) { return v->top; }
/* return the actual capacity */
inline int Vector_Cap(Vector *v) { return v->cap; }

@ -47,11 +47,13 @@ int Vector_Pop(Vector *v, void *ptr);
* Put an element at pos. * Put an element at pos.
* Note: If pos is outside the vector capacity, we resize it accordingly * Note: If pos is outside the vector capacity, we resize it accordingly
*/ */
#define Vector_Put(v, pos, elem) __vector_PutPtr(v, pos, elem ? &(typeof(elem)){elem} : NULL) #define Vector_Put(v, pos, elem) \
__vector_PutPtr(v, pos, elem ? &(typeof(elem)){elem} : NULL)
/* Push an element at the end of v, resizing it if needed. This macro wraps /* Push an element at the end of v, resizing it if needed. This macro wraps
* __vector_PushPtr */ * __vector_PushPtr */
#define Vector_Push(v, elem) __vector_PushPtr(v, elem ? &(typeof(elem)){elem} : NULL) #define Vector_Push(v, elem) \
__vector_PushPtr(v, elem ? &(typeof(elem)){elem} : NULL)
int __vector_PushPtr(Vector *v, void *elem); int __vector_PushPtr(Vector *v, void *elem);
@ -59,10 +61,10 @@ int __vector_PushPtr(Vector *v, void *elem);
int Vector_Resize(Vector *v, size_t newcap); int Vector_Resize(Vector *v, size_t newcap);
/* return the used size of the vector, regardless of capacity */ /* return the used size of the vector, regardless of capacity */
inline int Vector_Size(Vector *v) { return v->top; } int Vector_Size(Vector *v);
/* return the actual capacity */ /* return the actual capacity */
inline int Vector_Cap(Vector *v) { return v->cap; } int Vector_Cap(Vector *v);
/* free the vector and the underlying data. Does not release its elements if /* free the vector and the underlying data. Does not release its elements if
* they are pointers*/ * they are pointers*/

Loading…
Cancel
Save