Raydium 3D Game Engine
https://memak.raydium.org/

raydium_log et raydium_console_line_add
https://memak.raydium.org/viewtopic.php?f=8&t=342
Page 1 of 1

Author:  guitou [ Sun Apr 30, 2006 3:37 pm ]
Post subject:  raydium_log et raydium_console_line_add

Je me posais une petite question (conne, très certainement).
Pourquoi ne pas utiliser vfprintf dans la fonction raydium_log (log.c) ?

Je verrais bien un truc du genre :
Code:
void raydium_log(char * format, ...)
{
  va_list arg;

  va_start(arg, format);
  vfprintf(stdout, format, arg);
  if(raydium_log_file) vfprintf(raydium_log_file, format, arg);
  raydium_console_line_add(format, arg);
  va_end(arg);
}


En ce qui concerne raydium_console_line_add (console.c), un vsnprintf et strncpy seraient préférables également à mon humble avis.
Voilà voilà :)


--
guitou

Author:  Xfennec [ Tue May 09, 2006 11:39 am ]
Post subject: 

Eh bien pourquoi pas ! On évite effectivement quelques mauvaises surprises dûes à des débordements. Tu souhaites t'en charger ?

Author:  guitou [ Tue May 09, 2006 3:29 pm ]
Post subject: 

Eventuellement oui. Je vais faire quelques vérifications tout de même, j'ai cru lire un truc dans le man qui me plait moyen.

Quote:
int vprintf(const char *format, va_list ap);
int vfprintf(FILE *stream, const char *format, va_list ap);
int vsprintf(char *str, const char *format, va_list ap);
int vsnprintf(char *str, size_t size, const char *format, va_list ap);

The functions vprintf, vfprintf, vsprintf, vsnprintf are equivalent to the functions printf, fprintf, sprintf, snprintf, respectively,
except that they are called with a va_list instead of a variable number of arguments. These functions do not call the va_end macro.
Consequently, the value of ap is undefined after the call. The application should call va_end(ap) itself afterwards.


--
guitou

Author:  guitou [ Thu May 11, 2006 6:22 am ]
Post subject: 

(la suite de ce thread est dans http://memak.raydium.org/viewtopic.php?t=351)

--
guitou

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/