summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e77407b)
raw | patch | inline | side by side (parent: e77407b)
author | Kalle Wallin <kaw@linux.se> | |
Sun, 28 Mar 2004 21:27:11 +0000 (21:27 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Sun, 28 Mar 2004 21:27:11 +0000 (21:27 +0000) |
conf.c | patch | blob | history | |
list_window.c | patch | blob | history | |
main.c | patch | blob | history | |
mpc.c | patch | blob | history | |
options.c | patch | blob | history | |
screen.c | patch | blob | history | |
screen_file.c | patch | blob | history | |
screen_play.c | patch | blob | history | |
screen_utils.c | patch | blob | history |
index 12fc15a61609e619a3419820c09e4feae69cac76..170da5e5e19c80fb5871edcaca354ade9fa19fcf 100644 (file)
--- a/conf.c
+++ b/conf.c
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+
+#include <glib.h>
#include <ncurses.h>
#include "config.h"
{
D(perror(filename));
if( free_filename )
- free(filename);
+ g_free(filename);
return -1;
}
D(printf( "--\n\n" ));
if( free_filename )
- free(filename);
+ g_free(filename);
return 0;
}
diff --git a/list_window.c b/list_window.c
index d976ce05c351372b1f87efea8427f4f31dc3d89b..b04b817daab212dc7cc5a0e8d9750441273b89fc 100644 (file)
--- a/list_window.c
+++ b/list_window.c
{
list_window_t *lw;
- lw = malloc(sizeof(list_window_t));
+ lw = g_malloc(sizeof(list_window_t));
memset(lw, 0, sizeof(list_window_t));
lw->w = w;
lw->cols = width;
if( lw )
{
memset(lw, 0, sizeof(list_window_t));
- free(lw);
+ g_free(lw);
}
return NULL;
}
index 0bfcb74349ae9a1e6283bcb72373e036b0341d8f..56c18a31652bc4cebb16bb0d37075a7c60eca3be 100644 (file)
--- a/main.c
+++ b/main.c
fprintf(stderr,"Error: %s\n", mpc_error_str(mpc));
mpc_close(mpc);
}
+ g_free(options.host);
}
void
index f48d83cd7d904051281fffde5e85e351312b8fb8..785117fc9ad58c8b0ddd420d0a6696e2bc174a27 100644 (file)
--- a/mpc.c
+++ b/mpc.c
-/*
- * $Id: mpc.c,v 1.5 2004/03/17 23:19:21 kalle Exp $
- *
- */
-
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
if( c->connection )
mpd_closeConnection(c->connection);
if( c->cwd )
- free( c->cwd );
+ g_free( c->cwd );
return 0;
}
exit(EXIT_FAILURE);
}
- c = malloc(sizeof(mpd_client_t));
+ c = g_malloc(sizeof(mpd_client_t));
memset(c, 0, sizeof(mpd_client_t));
c->connection = connection;
- c->cwd = strdup("");
+ c->cwd = g_strdup("");
return c;
}
snprintf(buf, MAX_SONG_LENGTH, "%s - %s", song->artist, song->title);
name = utf8_to_locale(buf);
strncpy(buf, name, MAX_SONG_LENGTH);
- free(name);
+ g_free(name);
return buf;
}
else
{
name = utf8_to_locale(song->title);
strncpy(buf, name, MAX_SONG_LENGTH);
- free(name);
+ g_free(name);
return buf;
}
}
name = utf8_to_locale(basename(song->file));
strncpy(buf, name, MAX_SONG_LENGTH);
- free(name);
+ g_free(name);
return buf;
}
if( entry->entity )
mpd_freeInfoEntity(entry->entity);
- free(entry);
+ g_free(entry);
list=list->next;
}
g_list_free(c->filelist);
if( c->cwd && c->cwd[0] )
{
/* add a dummy entry for ./.. */
- filelist_entry_t *entry = malloc(sizeof(filelist_entry_t));
+ filelist_entry_t *entry = g_malloc(sizeof(filelist_entry_t));
memset(entry, 0, sizeof(filelist_entry_t));
entry->entity = NULL;
c->filelist = g_list_append(c->filelist, (gpointer) entry);
while( (entity=mpd_getNextInfoEntity(c->connection)) )
{
- filelist_entry_t *entry = malloc(sizeof(filelist_entry_t));
+ filelist_entry_t *entry = g_malloc(sizeof(filelist_entry_t));
memset(entry, 0, sizeof(filelist_entry_t));
entry->entity = entity;
diff --git a/options.c b/options.c
index f1840325b56440baddcf08c6d70804a68dd52db6..cf3bbca27142e1c76ff4dd2d1c1bd42ddbe97f2a 100644 (file)
--- a/options.c
+++ b/options.c
#include <unistd.h>
#include <string.h>
#include <ncurses.h>
+#include <glib.h>
#include <popt.h>
#include "config.h"
memset(&options, 0, sizeof(options_t));
if( (value=getenv(MPD_HOST_ENV)) )
- options.host = strdup(value);
+ options.host = g_strdup(value);
else
- options.host = strdup(DEFAULT_HOST);
+ options.host = g_strdup(DEFAULT_HOST);
if( (value=getenv(MPD_PORT_ENV)) )
options.port = atoi(value);
else
diff --git a/screen.c b/screen.c
index 3025d9a01f1718ba01b1e60b089772cd8ee320b4..67ecc18bf74b8c64d89aa62c605062df5ba0724f 100644 (file)
--- a/screen.c
+++ b/screen.c
screen->playlist = list_window_free(screen->playlist);
screen->filelist = list_window_free(screen->filelist);
screen->helplist = list_window_free(screen->helplist);
- free(screen->buf);
- free(screen->findbuf);
- free(screen);
+ g_free(screen->buf);
+ g_free(screen->findbuf);
+ g_free(screen);
screen = NULL;
}
return 0;
exit(EXIT_FAILURE);
}
- screen = malloc(sizeof(screen_t));
+ screen = g_malloc(sizeof(screen_t));
memset(screen, 0, sizeof(screen_t));
screen->mode = SCREEN_PLAY_WINDOW;
screen->cols = COLS;
screen->rows = LINES;
- screen->buf = malloc(screen->cols);
+ screen->buf = g_malloc(screen->cols);
screen->buf_size = screen->cols;
screen->findbuf = NULL;
screen->painted = 0;
diff --git a/screen_file.c b/screen_file.c
index c866566de66ba5e866add2223aa6c188e10cfdee..42d9456173ab211a02870b454b77d2e397d890ba 100644 (file)
--- a/screen_file.c
+++ b/screen_file.c
#define BUFSIZE 1024
-#undef USE_OLD_LAYOUT
+#define USE_OLD_LAYOUT
static char *
list_callback(int index, int *highlight, void *data)
#ifdef USE_OLD_LAYOUT
return "[..]";
#else
- return "<d> ..";
+ return "d ..";
#endif
}
if( entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY )
#ifdef USE_OLD_LAYOUT
snprintf(buf, BUFSIZE, "[%s]", dirname);
#else
- snprintf(buf, BUFSIZE, "<d> %s", dirname);
+ snprintf(buf, BUFSIZE, "d %s", dirname);
#endif
- free(dirname);
+ g_free(dirname);
return buf;
}
else if( entity->type==MPD_INFO_ENTITY_TYPE_SONG )
mpd_Song *song = entity->info.song;
#ifdef USE_OLD_LAYOUT
- return mpc_get_song_name(song));
+ return mpc_get_song_name(song);
#else
- snprintf(buf, BUFSIZE, "<m> %s", mpc_get_song_name(song));
+ snprintf(buf, BUFSIZE, "m %s", mpc_get_song_name(song));
return buf;
#endif
#ifdef USE_OLD_LAYOUT
snprintf(buf, BUFSIZE, "*%s*", filename);
#else
- snprintf(buf, BUFSIZE, "<p> %s", filename);
+ snprintf(buf, BUFSIZE, "p %s", filename);
#endif
- free(filename);
+ g_free(filename);
return buf;
}
return "Error: Unknow entry!";
parent[0] = '\0';
}
if( c->cwd )
- free(c->cwd);
+ g_free(c->cwd);
c->cwd = parent;
}
else
{
mpd_Directory *dir = entity->info.directory;
if( c->cwd )
- free(c->cwd);
- c->cwd = strdup(dir->path);
+ g_free(c->cwd);
+ c->cwd = g_strdup(dir->path);
}
else
return -1;
mpd_finishCommand(c->connection);
screen_status_printf("Loading playlist %s...", filename);
- free(filename);
+ g_free(filename);
return 0;
}
plf = entity->info.playlistFile;
str = utf8_to_locale(basename(plf->path));
snprintf(buf, BUFSIZE, "Delete playlist %s [y/n] ? ", str);
- free(str);
+ g_free(str);
key = tolower(screen_getch(screen->status_window.w, buf));
if( key!='y' )
{
{
str = utf8_to_locale(mpc_error_str(c));
screen_status_printf("Error: %s", str);
- free(str);
+ g_free(str);
beep();
return -1;
}
dirname = utf8_to_locale(dir);
screen_status_printf("Adding directory %s...\n", dirname);
- free(dirname);
+ g_free(dirname);
dirname = NULL;
mpd_sendLsInfoCommand(c->connection, dir);
TOP_HEADER_FILE ": %s ",
tmp
);
- free(tmp);
+ g_free(tmp);
return buf;
}
diff --git a/screen_play.c b/screen_play.c
index 5f93ad09331e0108cb57f05af4b7488d292b39c9..72c223ed33fbddb49c78a642400dace3758db3f3 100644 (file)
--- a/screen_play.c
+++ b/screen_play.c
/* send save command to mpd */
mpd_sendSaveCommand(c->connection, filename_utf8);
mpd_finishCommand(c->connection);
- free(filename_utf8);
+ g_free(filename_utf8);
/* handle errors */
if( mpc_error(c))
{
{
char *str = utf8_to_locale(mpc_error_str(c));
screen_status_message(str);
- free(str);
+ g_free(str);
}
else
screen_status_printf("Error: Unable to save playlist as %s", filename);
}
/* success */
screen_status_printf("Saved %s", filename);
- free(filename);
+ g_free(filename);
/* update the file list if it has been initalized */
if( c->filelist )
{
diff --git a/screen_utils.c b/screen_utils.c
index 61c212edc9431d2e63fa29c7db9a07ad4ede2ee3..b93069c22959259324ef8adc04aa95ab4906fb20 100644 (file)
--- a/screen_utils.c
+++ b/screen_utils.c
curs_set(1);
if( wgetnstr(w, buf, 256) == OK )
- line = strdup(buf);
+ line = g_strdup(buf);
noecho();
curs_set(0);
case CMD_LIST_RFIND:
if( screen->findbuf )
{
- free(screen->findbuf);
+ g_free(screen->findbuf);
screen->findbuf=NULL;
}
/* continue... */