Commit 0c8d6908 authored by Alexandre Julliard's avatar Alexandre Julliard

Avoid using strlen.

parent bfb98f66
...@@ -295,10 +295,11 @@ static inline void *wld_memset( void *dest, int val, size_t len ) ...@@ -295,10 +295,11 @@ static inline void *wld_memset( void *dest, int val, size_t len )
* %x prints a hex number * %x prints a hex number
* %s prints a string * %s prints a string
*/ */
static void wld_vsprintf(char *str, const char *fmt, va_list args ) static int wld_vsprintf(char *buffer, const char *fmt, va_list args )
{ {
static const char hex_chars[16] = "0123456789abcdef"; static const char hex_chars[16] = "0123456789abcdef";
const char *p = fmt; const char *p = fmt;
char *str = buffer;
while( *p ) while( *p )
{ {
...@@ -325,28 +326,31 @@ static void wld_vsprintf(char *str, const char *fmt, va_list args ) ...@@ -325,28 +326,31 @@ static void wld_vsprintf(char *str, const char *fmt, va_list args )
*str++ = *p++; *str++ = *p++;
} }
*str = 0; *str = 0;
return str - buffer;
} }
static void wld_printf(const char *fmt, ... ) static void wld_printf(const char *fmt, ... )
{ {
va_list args; va_list args;
char buffer[256]; char buffer[256];
int len;
va_start( args, fmt ); va_start( args, fmt );
wld_vsprintf(buffer, fmt, args ); len = wld_vsprintf(buffer, fmt, args );
va_end( args ); va_end( args );
wld_write(2, buffer, strlen(buffer)); wld_write(2, buffer, len);
} }
static __attribute__((noreturn)) void fatal_error(const char *fmt, ... ) static __attribute__((noreturn)) void fatal_error(const char *fmt, ... )
{ {
va_list args; va_list args;
char buffer[256]; char buffer[256];
int len;
va_start( args, fmt ); va_start( args, fmt );
wld_vsprintf(buffer, fmt, args ); len = wld_vsprintf(buffer, fmt, args );
va_end( args ); va_end( args );
wld_write(2, buffer, strlen(buffer)); wld_write(2, buffer, len);
wld_exit(1); wld_exit(1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment