[geany/geany] 2f1ad0: Remove most uses of glib calls

Jiří Techet git-noreply at xxxxx
Mon Dec 17 21:05:30 UTC 2018


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Sat, 08 Oct 2016 12:12:44 UTC
Commit:      2f1ad0232b4410f874ea7f7521e1f50302c88ffe
             https://github.com/geany/geany/commit/2f1ad0232b4410f874ea7f7521e1f50302c88ffe

Log Message:
-----------
Remove most uses of glib calls

Some special cases which require more work still remain, plus there's
still GRegex.


Modified Paths:
--------------
    ctags/main/entry.c
    ctags/main/lcpp.c
    ctags/main/parse.c
    ctags/main/read.c
    ctags/main/routines.c
    ctags/main/sort.c
    ctags/main/strlist.c

Modified: ctags/main/entry.c
14 lines changed, 6 insertions(+), 8 deletions(-)
===================================================================
@@ -15,8 +15,6 @@
 #include <string.h>
 #include <ctype.h>        /* to define isspace () */
 #include <errno.h>
-#include <glib.h>
-#include <glib/gstdio.h>
 
 #if defined (HAVE_SYS_TYPES_H)
 # include <sys/types.h>	  /* to declare off_t on some hosts */
@@ -247,7 +245,7 @@ static long unsigned int updatePseudoTags (MIO *const mio)
 static bool isTagFile (const char *const filename)
 {
 	bool ok = false;                 /* we assume not unless confirmed */
-	MIO *const mio = mio_new_file_full (filename, "rb", g_fopen, fclose);
+	MIO *const mio = mio_new_file (filename, "rb");
 
 	if (mio == NULL  &&  errno == ENOENT)
 		ok = true;
@@ -293,17 +291,17 @@ extern void openTagFile (void)
 
 		if (Option.append  &&  fileExists)
 		{
-			TagFile.mio = mio_new_file_full (TagFile.name, "r+", g_fopen, fclose);
+			TagFile.mio = mio_new_file (TagFile.name, "r+");
 			if (TagFile.mio != NULL)
 			{
 				TagFile.numTags.prev = updatePseudoTags (TagFile.mio);
 				mio_free (TagFile.mio);
-				TagFile.mio = mio_new_file_full (TagFile.name, "a+", g_fopen, fclose);
+				TagFile.mio = mio_new_file (TagFile.name, "a+");
 			}
 		}
 		else
 		{
-			TagFile.mio = mio_new_file_full (TagFile.name, "w", g_fopen, fclose);
+			TagFile.mio = mio_new_file (TagFile.name, "w");
 			if (TagFile.mio != NULL)
 				addPseudoTags ();
 		}
@@ -343,12 +341,12 @@ extern void copyBytes (MIO* const fromMio, MIO* const toMio, const long size)
 
 extern void copyFile (const char *const from, const char *const to, const long size)
 {
-	MIO* const fromMio = mio_new_file_full (from, "rb", g_fopen, fclose);
+	MIO* const fromMio = mio_new_file (from, "rb");
 	if (fromMio == NULL)
 		error (FATAL | PERROR, "cannot open file to copy");
 	else
 	{
-		MIO* const toMio = mio_new_file_full (to, "wb", g_fopen, fclose);
+		MIO* const toMio = mio_new_file (to, "wb");
 		if (toMio == NULL)
 			error (FATAL | PERROR, "cannot open copy destination");
 		else


Modified: ctags/main/lcpp.c
8 lines changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -14,7 +14,6 @@
 #include "general.h"  /* must always come first */
 
 #include <string.h>
-#include <glib.h>
 
 #include "debug.h"
 #include "entry.h"
@@ -23,6 +22,7 @@
 #include "options.h"
 #include "read.h"
 #include "vstring.h"
+#include "routines.h"
 
 /*
 *   MACROS
@@ -325,7 +325,7 @@ static void makeDefineTag (const char *const name, bool parameterized)
 		}
 		makeTagEntry (&e);
 		if (parameterized)
-			free((char *) e.extensionFields.signature);
+			eFree((char *) e.extensionFields.signature);
 	}
 }
 
@@ -968,13 +968,13 @@ extern char *cppGetArglistFromFilePos(MIOPos startPosition, const char *tokenNam
 	{
 		size_t len = pos2 - pos1;
 
-		result = (char *) g_malloc(len + 1);
+		result = (char *) eMalloc(len + 1);
 		if (result != NULL && (len = mio_read(File.mio, result, 1, len)) > 0)
 		{
 			result[len] = '\0';
 			arglist = getArglistFromStr(result, tokenName);
 		}
-		g_free(result);
+		eFree(result);
 	}
 	mio_setpos(File.mio, &originalPosition);
 	return arglist;


Modified: ctags/main/parse.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -172,7 +172,7 @@ static vString* determineInterpreter (const char* const cmd)
 static langType getInterpreterLanguage (const char *const fileName)
 {
 	langType result = LANG_IGNORE;
-	FILE* const fp = g_fopen (fileName, "r");
+	FILE* const fp = fopen (fileName, "r");
 	if (fp != NULL)
 	{
 		vString* const vLine = vStringNew ();


Modified: ctags/main/read.c
3 lines changed, 1 insertions(+), 2 deletions(-)
===================================================================
@@ -15,7 +15,6 @@
 
 #include <string.h>
 #include <ctype.h>
-#include <glib/gstdio.h>
 
 #define FILE_WRITE
 #include "read.h"
@@ -262,7 +261,7 @@ extern bool fileOpen (const char *const fileName, const langType language)
 		File.mio = NULL;
 	}
 
-	File.mio = mio_new_file_full (fileName, openMode, g_fopen, fclose);
+	File.mio = mio_new_file (fileName, openMode);
 	if (File.mio == NULL)
 		error (WARNING | PERROR, "cannot open \"%s\"", fileName);
 	else


Modified: ctags/main/routines.c
7 lines changed, 2 insertions(+), 5 deletions(-)
===================================================================
@@ -12,9 +12,6 @@
 */
 #include "general.h"  /* must always come first */
 
-#include <glib.h>
-#include <glib/gstdio.h>
-
 #include <errno.h>
 
 #ifdef HAVE_STDLIB_H
@@ -200,7 +197,7 @@ extern const char *getExecutableName (void)
 
 extern void *eMalloc (const size_t size)
 {
-	void *buffer = g_malloc (size);
+	void *buffer = malloc (size);
 
 	if (buffer == NULL)
 		error (FATAL, "out of memory");
@@ -225,7 +222,7 @@ extern void *eRealloc (void *const ptr, const size_t size)
 		buffer = eMalloc (size);
 	else
 	{
-		buffer = g_realloc (ptr, size);
+		buffer = realloc (ptr, size);
 		if (buffer == NULL)
 			error (FATAL, "out of memory");
 	}


Modified: ctags/main/sort.c
20 lines changed, 9 insertions(+), 11 deletions(-)
===================================================================
@@ -17,8 +17,6 @@
 #endif
 #include <string.h>
 #include <stdio.h>
-#include <glib.h>
-#include <glib/gstdio.h>
 
 #include "entry.h"
 #include "routines.h"
@@ -36,7 +34,7 @@
 
 extern void catFile (const char *const name)
 {
-	FILE *const fp = g_fopen (name, "r");
+	FILE *const fp = fopen (name, "r");
 
 	if (fp != NULL)
 	{
@@ -64,7 +62,7 @@ extern void externalSortTags (const bool toStdout)
 	PE_CONST char *const sortOrder2 = "LC_ALL=C";
 	const size_t length = 4 + strlen (sortOrder1) + strlen (sortOrder2) +
 			strlen (sortCommand) + (2 * strlen (tagFileName ()));
-	char *const cmd = (char *) g_try_malloc (length + 1);
+	char *const cmd = (char *) malloc (length + 1);
 	int ret = -1;
 
 	if (cmd != NULL)
@@ -87,7 +85,7 @@ extern void externalSortTags (const bool toStdout)
 #endif
 		verbose ("system (\"%s\")\n", cmd);
 		ret = system (cmd);
-		g_free (cmd);
+		free (cmd);
 
 	}
 	if (ret != 0)
@@ -135,7 +133,7 @@ static void writeSortedTags (
 		mio = mio_new_fp (stdout, NULL);
 	else
 	{
-		mio = mio_new_file_full (tagFileName (), "w", g_fopen, fclose);
+		mio = mio_new_file (tagFileName (), "w");
 		if (mio == NULL)
 			failedSort (mio, NULL);
 	}
@@ -164,15 +162,15 @@ extern void internalSortTags (const bool toStdout)
 	 */
 	size_t numTags = TagFile.numTags.added + TagFile.numTags.prev;
 	const size_t tableSize = numTags * sizeof (char *);
-	char **const table = (char **) g_try_malloc (tableSize);    /* line pointers */
+	char **const table = (char **) malloc (tableSize);    /* line pointers */
 	DebugStatement ( size_t mallocSize = tableSize; )   /* cumulative total */
 
 	if (table == NULL)
 		failedSort (mio, "out of memory");
 
 	/*  Open the tag file and place its lines into allocated buffers.
 	 */
-	mio = mio_new_file_full (tagFileName (), "r", g_fopen, fclose);
+	mio = mio_new_file (tagFileName (), "r");
 	if (mio == NULL)
 		failedSort (mio, NULL);
 	for (i = 0  ;  i < numTags  &&  ! mio_eof (mio)  ;  )
@@ -190,7 +188,7 @@ extern void internalSortTags (const bool toStdout)
 		{
 			const size_t stringSize = strlen (line) + 1;
 
-			table [i] = (char *) g_try_malloc (stringSize);
+			table [i] = (char *) malloc (stringSize);
 			if (table [i] == NULL)
 				failedSort (mio, "out of memory");
 			DebugStatement ( mallocSize += stringSize; )
@@ -210,8 +208,8 @@ extern void internalSortTags (const bool toStdout)
 
 	PrintStatus (("sort memory: %ld bytes\n", (long) mallocSize));
 	for (i = 0 ; i < numTags ; ++i)
-		g_free (table [i]);
-	g_free (table);
+		free (table [i]);
+	free (table);
 }
 
 #endif


Modified: ctags/main/strlist.c
3 lines changed, 1 insertions(+), 2 deletions(-)
===================================================================
@@ -16,7 +16,6 @@
 #ifdef HAVE_FNMATCH_H
 # include <fnmatch.h>
 #endif
-#include <glib/gstdio.h>
 
 #include "routines.h"
 #include "read.h"
@@ -90,7 +89,7 @@ extern stringList* stringListNewFromArgv (const char* const* const argv)
 extern stringList* stringListNewFromFile (const char* const fileName)
 {
 	stringList* result = NULL;
-	MIO* const mio = mio_new_file_full (fileName, "r", g_fopen, fclose);
+	MIO* const mio = mio_new_file (fileName, "r");
 	if (mio != NULL)
 	{
 		result = stringListNew ();



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list