Patch to improve MAD subsystem
- From: "Andrew V. Samoilov" <kai cmail ru>
- To: GNU Midnight Commander Development Team <mc-devel gnome org>
- Subject: Patch to improve MAD subsystem
- Date: Wed, 3 Jul 2002 15:46:05 +0300
Hi!
This patch improves MAD subsystem, so it is possible now to
see where are g_strconcat, g_strdup_printf or g_strdup_vprintf
were called.
ChangeLog:
* mad.[ch] [__GNUC__] (mad_strconcat): Use macro varargs.
(mad_strdup_printf): Likewise.
(mad_strdup_vprintf): Likewise.
* main.c [HAVE_MAD] (main): Release this_dir and other_dir.
--- src/mad.h Fri Dec 28 03:11:52 2001
+++ src/mad.h Thu Jun 20 15:27:35 2002
@@ -67,9 +67,18 @@
#define g_strdup(x) mad_strdup (x, __FILE__, __LINE__)
#define g_strndup(x, n) mad_strndup (x, n, __FILE__, __LINE__)
#define g_free(x) mad_free (x, __FILE__, __LINE__)
+#ifndef __GNUC__
#define g_strconcat mad_strconcat
#define g_strdup_printf mad_strdup_printf
#define g_strdup_vprintf mad_strdup_vprintf
+#else
+#define g_strconcat(first, argc...) \
+ mad_strconcat (__FILE__, __LINE__, first, ## argc)
+#define g_strdup_printf(format, argc...) \
+ mad_strdup_printf(__FILE__, __LINE__, format, ## argc)
+#define g_strdup_vprintf(format, argc...) \
+ mad_strdup_vprintf (__FILE__, __LINE__, format, ## argc)
+#endif
#define g_get_current_dir() mad_get_current_dir (__FILE__, __LINE__)
#endif /* MAD_GLIB */
@@ -84,9 +93,16 @@ char *mad_strndup (const char *s, int n,
void mad_free (void *ptr, const char *file, int line);
void mad_finalize (const char *file, int line);
char *mad_tempnam (char *s1, char *s2, const char *file, int line);
+#ifndef __GNUC__
char *mad_strconcat (const char *first, ...);
char *mad_strdup_printf (const char *format, ...);
char *mad_strdup_vprintf (const char *format, va_list args);
+#else
+char *mad_strconcat (const char *file, int line, const char *first, ...);
+char *mad_strdup_printf (const char *file, int line, const char *format, ...)
+ __attribute__ ((format (printf, 3, 4)));
+char *mad_strdup_vprintf (const char *file, int line, const char *format, va_list args);
+#endif
char *mad_get_current_dir (const char *file, int line);
#else
--- src/mad.c Sat Jun 1 23:55:58 2002
+++ src/mad.c Wed Jul 3 15:08:33 2002
@@ -39,6 +39,9 @@
#undef g_strndup
#undef g_free
#undef g_get_current_dir
+#undef g_strconcat
+#undef g_strdup_printf
+#undef g_strdup_vprintf
#include <stdlib.h>
#include <stdio.h>
@@ -346,8 +349,16 @@ void mad_finalize (const char *file, int
}
char *
+#ifndef __GNUC__
mad_strconcat (const char *first, ...)
+#else
+mad_strconcat (const char *file, int line, const char *first, ...)
+#endif
{
+#ifndef __GNUC__
+ const char *file = "(mad_strconcat)";
+ int line = 0;
+#endif
va_list ap;
long len;
char *data, *result;
@@ -361,7 +372,7 @@ mad_strconcat (const char *first, ...)
while ((data = va_arg (ap, char *)) != 0)
len += strlen (data);
- result = mad_alloc(len, "(mad_strconcat)", 0);
+ result = mad_alloc(len, file, line);
va_end (ap);
@@ -379,14 +390,22 @@ mad_strconcat (const char *first, ...)
/* These two functions grabbed from GLib's gstrfuncs.c */
char*
+#ifndef __GNUC__
mad_strdup_vprintf (const char *format, va_list args1)
+#else
+mad_strdup_vprintf (const char *file, int line, const char *format, va_list args1)
+#endif
{
+#ifndef __GNUC__
+ const char *file = "(mad_strdup_vprintf)";
+ int line = 0;
+#endif
char *buffer;
va_list args2;
G_VA_COPY (args2, args1);
- buffer = mad_alloc(g_printf_string_upper_bound(format, args1), "(mad_strdup_vprintf)", 0);
+ buffer = mad_alloc(g_printf_string_upper_bound(format, args1), file, line);
vsprintf (buffer, format, args2);
va_end (args2);
@@ -395,13 +414,21 @@ mad_strdup_vprintf (const char *format,
}
char*
+#ifndef __GNUC__
mad_strdup_printf (const char *format, ...)
+#else
+mad_strdup_printf (const char *file, int line, const char *format, ...)
+#endif
{
char *buffer;
va_list args;
va_start (args, format);
+#ifdef __GNUC__
+ buffer = mad_strdup_vprintf(file, line, format, args);
+#else
buffer = mad_strdup_vprintf(format, args);
+#endif
va_end (args);
return buffer;
--- src/main.c Thu Jun 6 14:33:51 2002
+++ src/main.c Wed Jul 3 09:19:40 2002
@@ -2777,6 +2791,10 @@ main (int argc, char *argv [])
#ifdef HAVE_CHARSET
free_codepages_list ();
#endif
+ if (this_dir)
+ g_free (this_dir);
+ if (other_dir)
+ g_free (other_dir);
#endif
mad_finalize (__FILE__, __LINE__);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]