Re: General advice on type casting



Olivier wrote:
Dear all,

Here is a sample of my code:
----------------------------------------------
void message_is(gchar *ff, int d, gchar *o){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o);
Sol_print_infos(texte); /* g_free(texte) */;
}

void message_sd(gchar *ff, gchar *d, double o){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o);
Sol_print_infos(texte); /* g_free(texte) */;
}

void message_iii(gchar *ff, int d, int o, int t){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o ,t);
Sol_print_infos(texte); /* g_free(texte) */;
}
----------------------------------------------
where you can guess that Sol_print_infos is the
guy that does the actual printing with style
and all.
I haven't been able to put all of them in one
piece of code. (And I have more !!). Efficiency
in terms of time is faily irrelevant at this
level.
Thanks in advance !
Amities,
Olivier

void message(char *fmt,...)
{
char *texte;
va_list ap;

texte = malloc(256);
if(texte != NULL) {
va_start(ap,fmt);
vsnprintf(gtexte, 256, fmt, ap);
va_end(ap);
Sol_print_infos(texte);
free(texte);
}
}
.



Relevant Pages