mirror of
https://github.com/eRgo35/dots.git
synced 2025-12-16 15:36:11 +01:00
moving software to separate submodules part 1
This commit is contained in:
35
desktop/.dmenu/patch/highpriority.c
Normal file
35
desktop/.dmenu/patch/highpriority.c
Normal file
@@ -0,0 +1,35 @@
|
||||
static char **hpitems = NULL;
|
||||
static int hplength = 0;
|
||||
|
||||
static char **
|
||||
tokenize(char *source, const char *delim, int *llen)
|
||||
{
|
||||
int listlength = 0, list_size = 0;
|
||||
char **list = NULL, *token;
|
||||
|
||||
token = strtok(source, delim);
|
||||
while (token) {
|
||||
if (listlength + 1 >= list_size) {
|
||||
if (!(list = realloc(list, (list_size += 8) * sizeof(*list))))
|
||||
die("Unable to realloc %zu bytes\n", list_size * sizeof(*list));
|
||||
}
|
||||
if (!(list[listlength] = strdup(token)))
|
||||
die("Unable to strdup %zu bytes\n", strlen(token) + 1);
|
||||
token = strtok(NULL, delim);
|
||||
listlength++;
|
||||
}
|
||||
|
||||
*llen = listlength;
|
||||
return list;
|
||||
}
|
||||
|
||||
static int
|
||||
arrayhas(char **list, int length, char *item) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
int len1 = strlen(list[i]);
|
||||
int len2 = strlen(item);
|
||||
if (fstrncmp(list[i], item, len1 > len2 ? len2 : len1) == 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user