mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
Another round of feedback from acrisci
This commit is contained in:
parent
43b20bfea2
commit
74ca2f8fcf
5 changed files with 44 additions and 42 deletions
21
util/array.c
Normal file
21
util/array.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
lib_wlr_util = static_library(
|
||||
'wlr_util',
|
||||
files(
|
||||
'array.c',
|
||||
'log.c',
|
||||
'os-compatibility.c',
|
||||
'region.c',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue