Rémi Bernon (@rbernon) commented about tools/winebuild/import.c:
ret = p = xmalloc( len * 4 + 1 ); for ( ; len > 0; len--, name++) {
if (!strchr( valid_chars, *name )) p += sprintf( p, "$x%02x", *name );
if (!strchr( valid_chars, *name ))
p += snprintf( p, (len * 4 + 1) - (p - ret), "$x%02x", *name );
This one look a bit awful, what about keeping an end pointer, initialized right after the alloc instead?