Alexandre Julliard : winebuild: Support an arbitrary number of temporary files.
Alexandre Julliard
julliard at winehq.org
Mon Aug 2 11:03:51 CDT 2010
Module: wine
Branch: master
Commit: f51e696cca9844c81d3a4627f9e41d6cc70e7b92
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f51e696cca9844c81d3a4627f9e41d6cc70e7b92
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Aug 2 10:11:43 2010 +0200
winebuild: Support an arbitrary number of temporary files.
---
tools/winebuild/utils.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index 6c99262..d5de220 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -39,9 +39,9 @@
#include "build.h"
-#define MAX_TMP_FILES 8
-static const char *tmp_files[MAX_TMP_FILES];
+static const char **tmp_files;
static unsigned int nb_tmp_files;
+static unsigned int max_tmp_files;
static const struct
{
@@ -66,7 +66,7 @@ static const struct
static void cleanup_tmp_files(void)
{
unsigned int i;
- for (i = 0; i < MAX_TMP_FILES; i++) if (tmp_files[i]) unlink( tmp_files[i] );
+ for (i = 0; i < nb_tmp_files; i++) if (tmp_files[i]) unlink( tmp_files[i] );
}
@@ -348,7 +348,6 @@ char *get_temp_file_name( const char *prefix, const char *suffix )
const char *ext;
int fd;
- assert( nb_tmp_files < MAX_TMP_FILES );
if (!nb_tmp_files && !save_temps) atexit( cleanup_tmp_files );
if (!prefix || !prefix[0]) prefix = "winebuild";
@@ -367,6 +366,11 @@ char *get_temp_file_name( const char *prefix, const char *suffix )
fatal_error( "could not generate a temp file\n" );
close( fd );
+ if (nb_tmp_files >= max_tmp_files)
+ {
+ max_tmp_files = max( 2 * max_tmp_files, 8 );
+ tmp_files = xrealloc( tmp_files, max_tmp_files * sizeof(tmp_files[0]) );
+ }
tmp_files[nb_tmp_files++] = name;
return name;
}
More information about the wine-cvs
mailing list