* 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.
This commit is contained in:
Pavel Roskin 2002-07-03 15:58:54 +00:00
parent 6ecbdd05ab
commit a83d080370
4 changed files with 56 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2002-07-03 Andrew V. Samoilov <kai@cmail.ru>
* 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.
2002-07-03 Pavel Roskin <proski@gnu.org>
* main.c (stop_dialogs): New function to stop all dialogs.

View File

@ -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 line)
}
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, va_list args1)
}
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;

View File

@ -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, const char *file, int line);
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

View File

@ -2791,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__);