Alexandre Julliard : wmc: Add a copy of the strmake utility function.
Alexandre Julliard
julliard at winehq.org
Tue Jan 25 12:01:37 CST 2011
Module: wine
Branch: master
Commit: 46ecc16deb1a3d2c2ffcf57085252796801759a0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=46ecc16deb1a3d2c2ffcf57085252796801759a0
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Jan 24 20:05:00 2011 +0100
wmc: Add a copy of the strmake utility function.
---
tools/wmc/utils.c | 21 +++++++++++++++++++--
tools/wmc/utils.h | 1 +
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/tools/wmc/utils.c b/tools/wmc/utils.c
index 88dd45f..6f26da3 100644
--- a/tools/wmc/utils.c
+++ b/tools/wmc/utils.c
@@ -138,7 +138,6 @@ void *xmalloc(size_t size)
void *res;
assert(size > 0);
- assert(size < 102400);
res = malloc(size);
if(res == NULL)
{
@@ -154,7 +153,6 @@ void *xrealloc(void *p, size_t size)
void *res;
assert(size > 0);
- assert(size < 102400);
res = realloc(p, size);
if(res == NULL)
{
@@ -172,6 +170,25 @@ char *xstrdup(const char *str)
return strcpy(s, str);
}
+char *strmake( const char* fmt, ... )
+{
+ int n;
+ size_t size = 100;
+ va_list ap;
+
+ for (;;)
+ {
+ char *p = xmalloc( size );
+ va_start( ap, fmt );
+ n = vsnprintf( p, size, fmt, ap );
+ va_end( ap );
+ if (n == -1) size *= 2;
+ else if ((size_t)n >= size) size = n + 1;
+ else return p;
+ free( p );
+ }
+}
+
int unistrlen(const WCHAR *s)
{
int n;
diff --git a/tools/wmc/utils.h b/tools/wmc/utils.h
index bef1abf..909cc99 100644
--- a/tools/wmc/utils.h
+++ b/tools/wmc/utils.h
@@ -33,6 +33,7 @@ char *xstrdup(const char *str);
#define __attribute__(X)
#endif
+char *strmake(const char* fmt, ...) __attribute__((__format__ (__printf__, 1, 2 )));
int mcy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
int xyyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int mcy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
More information about the wine-cvs
mailing list