diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-07-16 20:10:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-16 20:10:38 -0700 |
commit | 7f20ab644347b11fd8242beaf7a6fe42c910d014 (patch) | |
tree | 808d0e88c28561d5853be09f7c2ab7968ce70e3f /util | |
parent | 4984ea49eeaa292d66be9e535d93a4d8185f3e18 (diff) | |
parent | 9a6f77fc2ceb59f4b5bcd1e1f8c00aa974b5192b (diff) | |
download | wlroots-7f20ab644347b11fd8242beaf7a6fe42c910d014.tar.xz |
Merge pull request #960 from Ongy/tablet
tablet-unstable-v2 support
Diffstat (limited to 'util')
-rw-r--r-- | util/array.c | 21 | ||||
-rw-r--r-- | util/meson.build | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/util/array.c b/util/array.c new file mode 100644 index 00000000..9ee39d33 --- /dev/null +++ b/util/array.c @@ -0,0 +1,21 @@ +#include <stdlib.h> +#include <stdint.h> + +// https://www.geeksforgeeks.org/move-zeroes-end-array/ +size_t push_zeroes_to_end(uint32_t arr[], size_t n) { + size_t count = 0; + + for (size_t i = 0; i < n; i++) { + if (arr[i] != 0) { + arr[count++] = arr[i]; + } + } + + size_t ret = count; + + while (count < n) { + arr[count++] = 0; + } + + return ret; +} diff --git a/util/meson.build b/util/meson.build index adc52a53..f9d1997d 100644 --- a/util/meson.build +++ b/util/meson.build @@ -1,6 +1,7 @@ lib_wlr_util = static_library( 'wlr_util', files( + 'array.c', 'log.c', 'os-compatibility.c', 'region.c', |