James Hawkins : setupapi: Refactor freeing the INF file into free_inf_file. Use this new function to free any remnants of the parsing on error.
Alexandre Julliard
julliard at winehq.org
Thu Jan 7 13:08:36 CST 2010
Module: wine
Branch: master
Commit: b116175d4a5f4e818643c0b66dc8c4943f71d8cc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b116175d4a5f4e818643c0b66dc8c4943f71d8cc
Author: James Hawkins <truiken at gmail.com>
Date: Wed Jan 6 18:26:52 2010 -0800
setupapi: Refactor freeing the INF file into free_inf_file. Use this new function to free any remnants of the parsing on error.
---
dlls/setupapi/parser.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c
index 37b900f..7f581bd 100644
--- a/dlls/setupapi/parser.c
+++ b/dlls/setupapi/parser.c
@@ -856,6 +856,19 @@ static const WCHAR *comment_state( struct parser *parser, const WCHAR *pos )
}
+static void free_inf_file( struct inf_file *file )
+{
+ unsigned int i;
+
+ for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] );
+ HeapFree( GetProcessHeap(), 0, file->filename );
+ HeapFree( GetProcessHeap(), 0, file->sections );
+ HeapFree( GetProcessHeap(), 0, file->fields );
+ HeapFree( GetProcessHeap(), 0, file->strings );
+ HeapFree( GetProcessHeap(), 0, file );
+}
+
+
/* parse a complete buffer */
static DWORD parse_buffer( struct inf_file *file, const WCHAR *buffer, const WCHAR *end,
UINT *error_line )
@@ -1011,7 +1024,7 @@ static struct inf_file *parse_file( HANDLE handle, const WCHAR *class, DWORD sty
UnmapViewOfFile( buffer );
if (err)
{
- HeapFree( GetProcessHeap(), 0, file );
+ free_inf_file( file );
SetLastError( err );
file = NULL;
}
@@ -1231,16 +1244,10 @@ HINF WINAPI SetupOpenMasterInf( VOID )
void WINAPI SetupCloseInfFile( HINF hinf )
{
struct inf_file *file = hinf;
- unsigned int i;
if (!hinf || (hinf == INVALID_HANDLE_VALUE)) return;
- for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] );
- HeapFree( GetProcessHeap(), 0, file->filename );
- HeapFree( GetProcessHeap(), 0, file->sections );
- HeapFree( GetProcessHeap(), 0, file->fields );
- HeapFree( GetProcessHeap(), 0, file->strings );
- HeapFree( GetProcessHeap(), 0, file );
+ free_inf_file( file );
}
More information about the wine-cvs
mailing list