diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2022-01-18 12:01:56 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2022-01-18 12:27:29 -0500 |
commit | 6ac4deb451ccd4ed11fb0d022b83710b5b0522fe (patch) | |
tree | d1cc49bd9abca1aaa91c5a990e1cb521f5fa09ee /darray.c | |
parent | 60dc18c9fcb2550e15a35809818764ee43a178c7 (diff) | |
download | bfs-6ac4deb451ccd4ed11fb0d022b83710b5b0522fe.tar.xz |
darray: New DARRAY_POP() macro
Diffstat (limited to 'darray.c')
-rw-r--r-- | darray.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1,6 +1,6 @@ /**************************************************************************** * bfs * - * Copyright (C) 2019 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2019-2022 Tavian Barnes <tavianator@tavianator.com> * * * * Permission to use, copy, modify, and/or distribute this software for any * * purpose with or without fee is hereby granted. * @@ -15,6 +15,7 @@ ****************************************************************************/ #include "darray.h" +#include <assert.h> #include <stdlib.h> #include <string.h> @@ -96,6 +97,14 @@ int darray_check(void *da) { } } +size_t darray_pop(void *da) { + assert(da); + + struct darray *header = darray_header(da); + assert(header->length > 0); + return --header->length; +} + void darray_free(void *da) { if (da) { free(darray_header(da)); |