squareball  0.2.0.53-dd5b
A general-purpose library for C99
sb-slist.h
Go to the documentation of this file.
1 /*
2  * squareball: A general-purpose library for C99.
3  * Copyright (C) 2014-2018 Rafael G. Martins <rafael@rafaelmartins.eng.br>
4  *
5  * This program can be distributed under the terms of the BSD License.
6  * See the file LICENSE.
7  */
8 
9 #ifndef _SQUAREBALL_SLIST_H
10 #define _SQUAREBALL_SLIST_H
11 
12 #include "sb-mem.h"
13 
22 typedef struct _sb_slist_t {
23 
25  struct _sb_slist_t *next;
26 
28  void *data;
29 
30 } sb_slist_t;
31 
42 typedef int (*sb_sort_func_t) (const void *a, const void *b);
43 
52 sb_slist_t* sb_slist_append(sb_slist_t *l, void *data);
53 
62 sb_slist_t* sb_slist_prepend(sb_slist_t *l, void *data);
63 
72 
78 void sb_slist_free(sb_slist_t *l);
79 
87 void sb_slist_free_full(sb_slist_t *l, sb_free_func_t free_func);
88 
95 size_t sb_slist_length(sb_slist_t *l);
96 
99 #endif /* _SQUAREBALL_SLIST_H */
void sb_slist_free(sb_slist_t *l)
void sb_slist_free_full(sb_slist_t *l, sb_free_func_t free_func)
sb_slist_t * sb_slist_prepend(sb_slist_t *l, void *data)
size_t sb_slist_length(sb_slist_t *l)
struct _sb_slist_t * next
Definition: sb-slist.h:25
void(* sb_free_func_t)(void *ptr)
Definition: sb-mem.h:31
Definition: sb-slist.h:22
void * data
Definition: sb-slist.h:28
sb_slist_t * sb_slist_sort(sb_slist_t *l, sb_sort_func_t cmp)
int(* sb_sort_func_t)(const void *a, const void *b)
Definition: sb-slist.h:42
Memory allocation related helpers.
sb_slist_t * sb_slist_append(sb_slist_t *l, void *data)