Mercurial > hg > th-libs
comparison th_util.h @ 16:0cea9c0cfce7
Sync.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Nov 2010 23:22:44 +0200 |
parents | e467b3586e4d |
children | c0d5c825894a |
comparison
equal
deleted
inserted
replaced
15:4adf7093060c | 16:0cea9c0cfce7 |
---|---|
1 /* | 1 /* |
2 * Generic utility-functions, macros and defaults | 2 * Generic utility-functions, macros and defaults |
3 * Programmed and designed by Matti 'ccr' Hamalainen | 3 * Programmed and designed by Matti 'ccr' Hamalainen |
4 * (C) Copyright 2002-2009 Tecnic Software productions (TNSP) | 4 * (C) Copyright 2002-2010 Tecnic Software productions (TNSP) |
5 * | 5 * |
6 * Please read file 'COPYING' for information on license and distribution. | 6 * Please read file 'COPYING' for information on license and distribution. |
7 */ | 7 */ |
8 #ifndef _TH_UTIL_H | 8 #ifndef _TH_UTIL_H |
9 #define _TH_UTIL_H | 9 #define _TH_UTIL_H |
13 #endif | 13 #endif |
14 | 14 |
15 #include "th_types.h" | 15 #include "th_types.h" |
16 #include <stdarg.h> | 16 #include <stdarg.h> |
17 #include <stdlib.h> | 17 #include <stdlib.h> |
18 #include <sys/types.h> | |
18 #ifndef HAVE_NO_ASSERT | 19 #ifndef HAVE_NO_ASSERT |
19 #include <assert.h> | 20 #include <assert.h> |
20 #endif | 21 #endif |
21 | 22 |
22 #ifdef HAVE_STRING_H | 23 #ifdef HAVE_STRING_H |
81 #define th_memset memset | 82 #define th_memset memset |
82 #else | 83 #else |
83 void *th_memset(void *, int, size_t); | 84 void *th_memset(void *, int, size_t); |
84 #endif | 85 #endif |
85 | 86 |
87 | |
88 /* Doubly linked list handling | |
89 */ | |
90 typedef struct _qlist_t { | |
91 void *data; | |
92 size_t num; | |
93 struct _qlist_t *prev, *next; | |
94 } qlist_t; | |
95 | |
96 | |
97 qlist_t * th_llist_new(void *data); | |
98 void th_llist_free(qlist_t *list); | |
99 void th_llist_free_func(qlist_t *list, void (*freefunc)(void *data)); | |
100 | |
101 qlist_t * th_llist_append(qlist_t **list, void *data); | |
102 qlist_t * th_llist_prepend(qlist_t **list, void *data); | |
103 void th_llist_delete(qlist_t **list, const void *data); | |
104 void th_llist_delete_node(qlist_t **list, qlist_t *node); | |
105 | |
106 qlist_t * th_llist_get_nth(qlist_t *list, const size_t n); | |
107 size_t th_llist_length(const qlist_t *list); | |
108 ssize_t th_llist_position(const qlist_t *list, const qlist_t *node); | |
109 | |
110 qlist_t * th_llist_find(qlist_t *list, const void *data); | |
111 qlist_t * th_llist_find_func(qlist_t *list, const void *userdata, int (compare)(const void *, const void *)); | |
112 | |
113 | |
86 #ifdef __cplusplus | 114 #ifdef __cplusplus |
87 } | 115 } |
88 #endif | 116 #endif |
89 #endif /* _TH_UTIL_H */ | 117 #endif /* _TH_UTIL_H */ |