summary refs log tree commit diff stats
path: root/plugins/mpcinfo/mpcInfo.c
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2014-12-28 06:08:20 -0500
committerTingPing <tingping@tingping.se>2014-12-28 06:47:07 -0500
commit3f855f07f5d2e9a08a586436719358c40a46f29d (patch)
tree12ffd1b49265e33c10149632a4cd17afb7fe994a /plugins/mpcinfo/mpcInfo.c
parent83032b1aa3c3e5910c5cfd3e0ea1d25827f56475 (diff)
Use glib for allocations in all plugins
Continuation of 83032b1aa
Diffstat (limited to 'plugins/mpcinfo/mpcInfo.c')
-rw-r--r--plugins/mpcinfo/mpcInfo.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/plugins/mpcinfo/mpcInfo.c b/plugins/mpcinfo/mpcInfo.c
index 4ab16642..4ad17689 100644
--- a/plugins/mpcinfo/mpcInfo.c
+++ b/plugins/mpcinfo/mpcInfo.c
@@ -48,12 +48,20 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
 	   HWND hwnd = FindWindow("MediaPlayerClassicW",NULL);
        if (hwnd==0) {hexchat_print(ph, randomLine(notRunTheme));return HEXCHAT_EAT_ALL;}
        
-       tTitle=(char*)malloc(sizeof(char)*1024);
+       tTitle = g_new(char, 1024);
        GetWindowText(hwnd, tTitle, 1024);
-       zero=strstr(tTitle," - Media Player Classic");
-       if (zero!=NULL) zero[0]=0;
-       else hexchat_print(ph,"pattern not found");
-       
+       zero = strstr (tTitle, " - Media Player Classic");
+	   if (zero != NULL)
+	   {
+		   zero[0] = 0;
+	   }
+	   else
+	   {
+		   g_free(tTitle);
+		   hexchat_print(ph, "pattern not found");
+		   return HEXCHAT_EAT_ALL;
+	   }
+
        if ((tTitle[1]==':')&&(tTitle[2]=='\\')){
           //hexchat_print(ph,"seams to be full path");
           if (endsWith(tTitle,".mp3")==1){
@@ -82,7 +90,8 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
                 //mp3Line=intReplace(mp3Line,"%perc",perc);
                 //mp3Line=replace(mp3Line,"%plTitle",title);
                 mp3Line=replace(mp3Line,"%file",tTitle);
-                hexchat_command(ph, mp3Line);
+				g_free(tTitle);
+				hexchat_command(ph, mp3Line);
                 return HEXCHAT_EAT_ALL;
              }
           }
@@ -111,14 +120,16 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
                 //oggLine=intReplace(oggLine,"%perc",perc);
                 //oggLine=replace(oggLine,"%plTitle",title);
                 oggLine=replace(oggLine,"%file",tTitle);
-                hexchat_command(ph, oggLine);
+				g_free(tTitle);
+				hexchat_command(ph, oggLine);
                 return HEXCHAT_EAT_ALL;
              }
           }
        }
        line=randomLine(titleTheme);
        line=replace(line,"%title", tTitle);
-       hexchat_command(ph,line); 
+	   g_free(tTitle);
+	   hexchat_command(ph, line);
        return HEXCHAT_EAT_ALL;
 }