summaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorThorsten Wißmann <edu@thorsten-wissmann.de>2012-07-14 13:38:46 +0200
committerThorsten Wißmann <edu@thorsten-wissmann.de>2012-07-21 02:16:02 +0200
commitba891aeb8d494dc1a2ebad5e345544beb82b1fde (patch)
treebe61290cc4589f7918acb64a7cfa68567ac7f9a4 /src/utils.c
parent680d1bf9c34ecc3c06690e64e91744ffcaa32e4c (diff)
stack: Maintain a monitor stack
This adds a monitor stack from which the information about the monitor stacking order can be retrieved. Currently, monitors aren't added to that stack yet.
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c
index 0a4d203d..3f027eb1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -256,6 +256,15 @@ int array_find(void* buf, size_t elems, size_t size, void* needle) {
return -1;
}
+void array_reverse(void* buf, size_t elems, size_t size) {
+ void* tmp = malloc(size);
+ for (int i = 0, j = elems - 1; i < j; i++, j--) {
+ memcpy(tmp, buf+i, size);
+ memcpy(buf+i, buf+j, size);
+ memcpy(buf+j, tmp, size);
+ }
+ free(tmp);
+}
/**
@@ -304,4 +313,3 @@ void* table_find(void* start, size_t elem_size, size_t count,
return NULL;
}
-