aboutsummaryrefslogtreecommitdiffstats
path: root/src/dirvec.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-08 10:49:05 +0200
committerMax Kellermann <max@duempel.org>2008-10-08 10:49:05 +0200
commit25f67da58c671885c86ecfd991f28ec82b6ce1e2 (patch)
tree7da9638ff323573d2aa53e70337866f8935114a0 /src/dirvec.c
parent3c1142cbcbd428ac5784ef098ac5e7a393647aa6 (diff)
downloadmpd-25f67da58c671885c86ecfd991f28ec82b6ce1e2.tar.gz
mpd-25f67da58c671885c86ecfd991f28ec82b6ce1e2.tar.xz
mpd-25f67da58c671885c86ecfd991f28ec82b6ce1e2.zip
directory: converted typedef Directory to struct directory
The struct can be forward-declared by other headers, which relaxes the header dependencies.
Diffstat (limited to 'src/dirvec.c')
-rw-r--r--src/dirvec.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/dirvec.c b/src/dirvec.c
index f84aa37fc..9226fca74 100644
--- a/src/dirvec.c
+++ b/src/dirvec.c
@@ -1,26 +1,27 @@
#include "dirvec.h"
+#include "directory.h"
#include "os_compat.h"
#include "utils.h"
static size_t dv_size(struct dirvec *dv)
{
- return dv->nr * sizeof(Directory *);
+ return dv->nr * sizeof(struct directory *);
}
/* Only used for sorting/searching a dirvec, not general purpose compares */
static int dirvec_cmp(const void *d1, const void *d2)
{
- const Directory *a = ((const Directory * const *)d1)[0];
- const Directory *b = ((const Directory * const *)d2)[0];
+ const struct directory *a = ((const struct directory * const *)d1)[0];
+ const struct directory *b = ((const struct directory * const *)d2)[0];
return strcmp(a->path, b->path);
}
void dirvec_sort(struct dirvec *dv)
{
- qsort(dv->base, dv->nr, sizeof(Directory *), dirvec_cmp);
+ qsort(dv->base, dv->nr, sizeof(struct directory *), dirvec_cmp);
}
-Directory *dirvec_find(struct dirvec *dv, const char *path)
+struct directory *dirvec_find(struct dirvec *dv, const char *path)
{
int i;
@@ -30,7 +31,7 @@ Directory *dirvec_find(struct dirvec *dv, const char *path)
return NULL;
}
-int dirvec_delete(struct dirvec *dv, Directory *del)
+int dirvec_delete(struct dirvec *dv, struct directory *del)
{
int i;
@@ -43,7 +44,7 @@ int dirvec_delete(struct dirvec *dv, Directory *del)
dv->base = NULL;
} else {
memmove(&dv->base[i], &dv->base[i + 1],
- (dv->nr - i + 1) * sizeof(Directory *));
+ (dv->nr - i + 1) * sizeof(struct directory *));
dv->base = xrealloc(dv->base, dv_size(dv));
}
return i;
@@ -52,7 +53,7 @@ int dirvec_delete(struct dirvec *dv, Directory *del)
return -1; /* not found */
}
-void dirvec_add(struct dirvec *dv, Directory *add)
+void dirvec_add(struct dirvec *dv, struct directory *add)
{
++dv->nr;
dv->base = xrealloc(dv->base, dv_size(dv));