summary refs log tree commit diff stats
path: root/plugins/mpcinfo
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mpcinfo')
-rw-r--r--plugins/mpcinfo/functions.c6
-rw-r--r--plugins/mpcinfo/mpcInfo.c27
-rw-r--r--plugins/mpcinfo/mpcinfo.vcxproj8
3 files changed, 29 insertions, 12 deletions
diff --git a/plugins/mpcinfo/functions.c b/plugins/mpcinfo/functions.c
index de2e8a40..e5993948 100644
--- a/plugins/mpcinfo/functions.c
+++ b/plugins/mpcinfo/functions.c
@@ -14,6 +14,8 @@
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <glib.h>
+
 char *split(char *text, char separator)
 {
 	int pos = -1;
@@ -67,7 +69,7 @@ int inStr(char *s1, size_t sl1, char *s2)
 
 static char *subString(char *text, int first, int length, int spcKill){
 //if (DEBUG==1) putlog("creating substring");
-	char *ret=(char*) calloc (length+1,sizeof(char)); //malloc(sizeof(char)*(length+1));
+	char *ret = g_new (char, length + 1);
 	int i;
 	ret[length]=0;
 	for (i=0;i<length;i++){
@@ -89,7 +91,7 @@ static char *substring(char *text, int first, int length){return subString(text,
 
 char *readLine(FILE *f){
      //if (DEBUG==1) putlog("reading line from file");
-     char *buffer=(char*)calloc(1024,sizeof(char)); //malloc(sizeof(char)*1024);
+     char *buffer = g_new (char, 1024);
      int pos=0;
      int cc=0;
      while((cc!=EOF)&&(pos<1024)&&(cc!=10)){
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;
 }
 
diff --git a/plugins/mpcinfo/mpcinfo.vcxproj b/plugins/mpcinfo/mpcinfo.vcxproj
index f69e8968..4eb901ab 100644
--- a/plugins/mpcinfo/mpcinfo.vcxproj
+++ b/plugins/mpcinfo/mpcinfo.vcxproj
@@ -63,13 +63,15 @@
       <IntrinsicFunctions>true</IntrinsicFunctions>

       <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

       <MultiProcessorCompilation>true</MultiProcessorCompilation>

-      <AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+      <AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

     </ClCompile>

     <Link>

       <SubSystem>Windows</SubSystem>

       <GenerateDebugInformation>true</GenerateDebugInformation>

       <EnableCOMDATFolding>true</EnableCOMDATFolding>

       <OptimizeReferences>true</OptimizeReferences>

+      <AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

+      <AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>

       <ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>

     </Link>

   </ItemDefinitionGroup>

@@ -81,13 +83,15 @@
       <IntrinsicFunctions>true</IntrinsicFunctions>

       <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

       <MultiProcessorCompilation>true</MultiProcessorCompilation>

-      <AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+      <AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

     </ClCompile>

     <Link>

       <SubSystem>Windows</SubSystem>

       <GenerateDebugInformation>true</GenerateDebugInformation>

       <EnableCOMDATFolding>true</EnableCOMDATFolding>

       <OptimizeReferences>true</OptimizeReferences>

+      <AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

+      <AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>

       <ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>

     </Link>

   </ItemDefinitionGroup>