mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
make the whole stuff run and clean it self up again
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@8 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
aae40dcea2
commit
7dfeb1fc74
11 changed files with 189 additions and 104 deletions
69
src/module.c
69
src/module.c
|
|
@ -3,66 +3,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "module.h"
|
||||
|
||||
|
||||
static void free_deps(struct dependency_module** deps) {
|
||||
assert(deps);
|
||||
|
||||
while (*deps) {
|
||||
struct dependency_module *next = (*deps)->next;
|
||||
lt_dlclose((*deps)->dl);
|
||||
free(deps);
|
||||
*deps = next;
|
||||
}
|
||||
}
|
||||
|
||||
static int load_deps(const char *fname, struct dependency_module **deps) {
|
||||
char line[PATH_MAX];
|
||||
FILE *f;
|
||||
char depfile[PATH_MAX];
|
||||
assert(fname && deps);
|
||||
|
||||
snprintf(depfile, sizeof(depfile), "%s.moddep", fname);
|
||||
|
||||
if (!(f = fopen(depfile, "r")))
|
||||
return -1;
|
||||
|
||||
while (fgets(line, sizeof(line)-1, f)) {
|
||||
lt_dlhandle dl;
|
||||
char *p;
|
||||
size_t l;
|
||||
struct dependency_module* d;
|
||||
|
||||
p = line + strspn(line, " \t");
|
||||
|
||||
l = strlen(p);
|
||||
if (p[l-1] == '\n')
|
||||
p[l-1] = 0;
|
||||
|
||||
if (*p == '#' || *p == 0)
|
||||
continue;
|
||||
|
||||
load_deps(p, deps);
|
||||
|
||||
if (!(dl = lt_dlopenext(p))) {
|
||||
free_deps(deps);
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
d = malloc(sizeof(struct dependency_module));
|
||||
assert(d);
|
||||
d->dl = dl;
|
||||
d->next = *deps;
|
||||
*deps = d;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct module* module_load(struct core *c, const char *name, const char *argument) {
|
||||
struct module *m = NULL;
|
||||
int r;
|
||||
|
|
@ -72,12 +16,6 @@ struct module* module_load(struct core *c, const char *name, const char *argumen
|
|||
m = malloc(sizeof(struct module));
|
||||
assert(m);
|
||||
|
||||
m->dl = NULL;
|
||||
|
||||
m->dependencies = NULL;
|
||||
if (load_deps(name, &m->dependencies) < 0)
|
||||
goto fail;
|
||||
|
||||
if (!(m->dl = lt_dlopenext(name)))
|
||||
goto fail;
|
||||
|
||||
|
|
@ -106,10 +44,12 @@ struct module* module_load(struct core *c, const char *name, const char *argumen
|
|||
|
||||
fail:
|
||||
if (m) {
|
||||
free(m->argument);
|
||||
free(m->name);
|
||||
|
||||
if (m->dl)
|
||||
lt_dlclose(m->dl);
|
||||
|
||||
free_deps(&m->dependencies);
|
||||
free(m);
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +61,6 @@ static void module_free(struct module *m) {
|
|||
m->done(m->core, m);
|
||||
|
||||
lt_dlclose(m->dl);
|
||||
free_deps(&m->dependencies);
|
||||
free(m->name);
|
||||
free(m->argument);
|
||||
free(m);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue