aboutsummaryrefslogtreecommitdiffhomepage
path: root/wutil.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2005-11-03 01:41:59 +1000
committerGravatar axel <axel@liljencrantz.se>2005-11-03 01:41:59 +1000
commit8d58e58d7bb53e77752ea2897d100398ac62ace7 (patch)
treec896c3cedbc0bec4230922f442a75473d5007103 /wutil.c
parentc8c3715aac2827c9e8b08ad7a5a56b2d88325d14 (diff)
Minor performance tweaks
darcs-hash:20051102154159-ac50b-9a32fb6cc654c593048840ebd9f6abb97c2e0bb8.gz
Diffstat (limited to 'wutil.c')
-rw-r--r--wutil.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/wutil.c b/wutil.c
index 560ded68..897aef41 100644
--- a/wutil.c
+++ b/wutil.c
@@ -22,6 +22,8 @@
#include "common.h"
#include "wutil.h"
+#define TMP_LEN_MIN 256
+
/**
Buffer for converting wide arguments to narrow arguments, used by
the \c wutil_wcs2str() function.
@@ -37,6 +39,10 @@ static size_t tmp_len=0;
*/
static int wutil_calls = 0;
+void wutil_init()
+{
+}
+
void wutil_destroy()
{
free( tmp );
@@ -57,8 +63,8 @@ static char *wutil_wcs2str( const wchar_t *in )
size_t new_sz =MAX_UTF8_BYTES*wcslen(in)+1;
if( tmp_len < new_sz )
{
- free( tmp );
- tmp = malloc( new_sz );
+ new_sz = maxi( new_sz, TMP_LEN_MIN );
+ tmp = realloc( tmp, new_sz );
if( !tmp )
{
die_mem();