This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository legacy-imlib2.
View the commit online.
commit 7ec44e68cb6e7ab1a4ef8a953bdf3e5dfdcfd687
Author: Kim Woelders <[email protected]>
AuthorDate: Tue Jun 21 19:15:46 2022 +0200
modules: Eliminate __imlib_TrimLoaderList()
Instead, don't put in the list what we would take out later.
---
src/lib/modules.c | 68 +++++++++++++++++--------------------------------------
src/lib/types.h | 1 +
2 files changed, 22 insertions(+), 47 deletions(-)
diff --git a/src/lib/modules.c b/src/lib/modules.c
index c563fcf..6d9f29e 100644
--- a/src/lib/modules.c
+++ b/src/lib/modules.c
@@ -61,59 +61,34 @@ __imlib_PathToLoaders(void)
return path;
}
-static char **
-__imlib_TrimLoaderList(char **list, int *num)
+static bool
+_file_is_module(const char *name)
{
- int i, n, size = 0;
+ const char *ext;
- if (!list)
- return NULL;
-
- n = *num;
-
- for (i = 0; i < n; i++)
- {
- char *ext;
+ ext = strrchr(name, '.');
+ if (!ext)
+ return false;
- if (!list[i])
- continue;
- ext = strrchr(list[i], '.');
- if ((ext) && (
+ if (
#ifdef __CYGWIN__
- (!strcasecmp(ext, ".dll")) ||
+ strcasecmp(ext, ".dll") != 0 &&
#endif
- (!strcasecmp(ext, ".so"))))
- {
- /* Don't add the same loader multiple times... */
- if (!__imlib_ItemInList(list, size, list[i]))
- {
- list[size++] = list[i];
- continue;
- }
- }
- free(list[i]);
- }
- if (!size)
- {
- free(list);
- list = NULL;
- }
- else
- {
- list = realloc(list, size * sizeof(char *));
- }
- *num = size;
- return list;
+ strcasecmp(ext, ".so") != 0)
+ return false;
+
+ return true;
}
char **
__imlib_ListModules(const char *path, int *num_ret)
{
char **list = NULL, **l;
- char file[1024];
- int num, i;
+ char file[1024], *p;
+ int num, i, ntot;
*num_ret = 0;
+ ntot = 0;
l = __imlib_FileDir(path, &num);
if (num <= 0)
@@ -124,18 +99,17 @@ __imlib_ListModules(const char *path, int *num_ret)
{
for (i = 0; i < num; i++)
{
+ if (!_file_is_module(l[i]))
+ continue;
snprintf(file, sizeof(file), "%s/%s", path, l[i]);
- list[i] = strdup(file);
+ p = strdup(file);
+ if (p)
+ list[ntot++] = p;
}
- *num_ret = num;
}
__imlib_FileFreeDirList(l, num);
- /* List currently contains *everything in there* we need to weed out
- * the .so, .la, .a versions of the same loader or whatever else.
- * dlopen can take an extension-less name and do the Right Thing
- * with it, so that's what we'll give it. */
- list = __imlib_TrimLoaderList(list, num_ret);
+ *num_ret = ntot;
return list;
}
diff --git a/src/lib/types.h b/src/lib/types.h
index e0b9aad..55b41ac 100644
--- a/src/lib/types.h
+++ b/src/lib/types.h
@@ -1,6 +1,7 @@
#ifndef TYPES_H
#define TYPES_H 1
+#include <stdbool.h>
#include <stdint.h>
typedef struct _ImlibLoader ImlibLoader;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.