projects
/
platform
/
upstream
/
libxkbcommon.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
packaging: make a option to select enable/disable tools
[platform/upstream/libxkbcommon.git]
/
src
/
darray.h
diff --git
a/src/darray.h
b/src/darray.h
index
c30fd7d
..
b75d85f
100644
(file)
--- a/
src/darray.h
+++ b/
src/darray.h
@@
-104,7
+104,7
@@
typedef darray (unsigned long) darray_ulong;
#define darray_from_items(arr, items, count) do { \
unsigned __count = (count); \
darray_resize(arr, __count); \
#define darray_from_items(arr, items, count) do { \
unsigned __count = (count); \
darray_resize(arr, __count); \
- if (count != 0) \
+ if (
__
count != 0) \
memcpy((arr).item, items, __count * sizeof(*(arr).item)); \
} while (0)
memcpy((arr).item, items, __count * sizeof(*(arr).item)); \
} while (0)
@@
-114,6
+114,11
@@
typedef darray (unsigned long) darray_ulong;
#define darray_concat(arr_to, arr_from) \
darray_append_items((arr_to), (arr_from).item, (arr_from).size)
#define darray_concat(arr_to, arr_from) \
darray_append_items((arr_to), (arr_from).item, (arr_from).size)
+/*** Removal ***/
+
+/* Warning: Do not call darray_remove_last on an empty darray. */
+#define darray_remove_last(arr) (--(arr).size)
+
/*** String buffer ***/
#define darray_append_string(arr, str) do { \
/*** String buffer ***/
#define darray_append_string(arr, str) do { \
@@
-206,4
+211,7
@@
darray_next_alloc(unsigned alloc, unsigned need, unsigned itemSize)
(idx) < (arr).size; \
(idx)++, (val)++)
(idx) < (arr).size; \
(idx)++, (val)++)
+#define darray_foreach_reverse(i, arr) \
+ for ((i) = &(arr).item[(arr).size - 1]; (arr).size > 0 && (i) >= &(arr).item[0]; (i)--)
+
#endif /* CCAN_DARRAY_H */
#endif /* CCAN_DARRAY_H */