diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-12-22 20:48:33 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-01-28 17:06:02 +0100 |
commit | ab6e81997cf8c5bcf7d1778bb32d8e01425b13f1 (patch) | |
tree | 76393dc9096d093e9ace8b263924055d3c8a13be /src | |
parent | d6830301f215e96328fa4f9a5ad9e253830386c3 (diff) | |
download | blogc-ab6e81997cf8c5bcf7d1778bb32d8e01425b13f1.tar.gz blogc-ab6e81997cf8c5bcf7d1778bb32d8e01425b13f1.tar.bz2 blogc-ab6e81997cf8c5bcf7d1778bb32d8e01425b13f1.zip |
common: utils: added bc_slist_pop()
Diffstat (limited to 'src')
-rw-r--r-- | src/common/utils.c | 13 | ||||
-rw-r--r-- | src/common/utils.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/common/utils.c b/src/common/utils.c index 97fa671..c78229d 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -105,6 +105,19 @@ bc_slist_length(bc_slist_t *l) } +bc_slist_t* +bc_slist_pop(bc_slist_t *l, void **data) +{ + if (l == NULL) + return l; + bc_slist_t *tmp = l; + l = l->next; + *data = tmp->data; + free(tmp); + return l; +} + + char* bc_strdup(const char *s) { diff --git a/src/common/utils.h b/src/common/utils.h index b0388b3..811c593 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -35,6 +35,10 @@ void bc_slist_free(bc_slist_t *l); void bc_slist_free_full(bc_slist_t *l, bc_free_func_t free_func); size_t bc_slist_length(bc_slist_t *l); +// here i'm just extending slist, instead of implementing a fully featuered +// queue for the sake of simplicity +bc_slist_t* bc_slist_pop(bc_slist_t *l, void **data); + // strfuncs |