diff options
author | Max Kellermann <max@duempel.org> | 2009-01-03 14:53:02 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-03 14:53:02 +0100 |
commit | 2064e8ac4cb4c7b7c69042e6dc1715c18777b983 (patch) | |
tree | 174d22c84c99770f2f557796aa2692d8d71e7389 /src | |
parent | 457301d97b9041747c8c019ab1e108b883bc85cc (diff) | |
download | mpd-2064e8ac4cb4c7b7c69042e6dc1715c18777b983.tar.gz mpd-2064e8ac4cb4c7b7c69042e6dc1715c18777b983.tar.xz mpd-2064e8ac4cb4c7b7c69042e6dc1715c18777b983.zip |
songvec, dirvec: use GLib instead of utils.h
Diffstat (limited to 'src')
-rw-r--r-- | src/dirvec.c | 11 | ||||
-rw-r--r-- | src/songvec.c | 17 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/dirvec.c b/src/dirvec.c index 6e921a75b..774730382 100644 --- a/src/dirvec.c +++ b/src/dirvec.c @@ -1,12 +1,11 @@ #include "dirvec.h" #include "directory.h" -#include "utils.h" -#include "path.h" #include <glib.h> #include <assert.h> #include <string.h> +#include <stdlib.h> static GMutex *nr_lock = NULL; @@ -74,13 +73,13 @@ int dirvec_delete(struct dirvec *dv, struct directory *del) /* we _don't_ call directory_free() here */ if (!--dv->nr) { g_mutex_unlock(nr_lock); - free(dv->base); + g_free(dv->base); dv->base = NULL; return i; } else { memmove(&dv->base[i], &dv->base[i + 1], (dv->nr - i) * sizeof(struct directory *)); - dv->base = xrealloc(dv->base, dv_size(dv)); + dv->base = g_realloc(dv->base, dv_size(dv)); } break; } @@ -93,7 +92,7 @@ void dirvec_add(struct dirvec *dv, struct directory *add) { g_mutex_lock(nr_lock); ++dv->nr; - dv->base = xrealloc(dv->base, dv_size(dv)); + dv->base = g_realloc(dv->base, dv_size(dv)); dv->base[dv->nr - 1] = add; g_mutex_unlock(nr_lock); } @@ -104,7 +103,7 @@ void dirvec_destroy(struct dirvec *dv) dv->nr = 0; g_mutex_unlock(nr_lock); if (dv->base) { - free(dv->base); + g_free(dv->base); dv->base = NULL; } } diff --git a/src/songvec.c b/src/songvec.c index 0e2adb7e5..17f60ab3b 100644 --- a/src/songvec.c +++ b/src/songvec.c @@ -1,9 +1,11 @@ #include "songvec.h" #include "song.h" -#include "utils.h" + +#include <glib.h> #include <assert.h> #include <string.h> +#include <stdlib.h> static GMutex *nr_lock = NULL; @@ -68,12 +70,12 @@ songvec_delete(struct songvec *sv, const struct song *del) continue; /* we _don't_ call song_free() here */ if (!--sv->nr) { - free(sv->base); + g_free(sv->base); sv->base = NULL; } else { memmove(&sv->base[i], &sv->base[i + 1], (sv->nr - i) * sizeof(struct song *)); - sv->base = xrealloc(sv->base, sv_size(sv)); + sv->base = g_realloc(sv->base, sv_size(sv)); } g_mutex_unlock(nr_lock); return i; @@ -88,7 +90,7 @@ songvec_add(struct songvec *sv, struct song *add) { g_mutex_lock(nr_lock); ++sv->nr; - sv->base = xrealloc(sv->base, sv_size(sv)); + sv->base = g_realloc(sv->base, sv_size(sv)); sv->base[sv->nr - 1] = add; g_mutex_unlock(nr_lock); } @@ -98,10 +100,9 @@ void songvec_destroy(struct songvec *sv) g_mutex_lock(nr_lock); sv->nr = 0; g_mutex_unlock(nr_lock); - if (sv->base) { - free(sv->base); - sv->base = NULL; - } + + g_free(sv->base); + sv->base = NULL; } int |