Author: tkreuzer Date: Thu Mar 11 00:37:47 2010 New Revision: 46084
URL: http://svn.reactos.org/svn/reactos?rev=46084&view=rev Log: [HPP] - Fix allocation size - add some more traces - add to build
Modified: branches/header-work/tools/hpp/hpp.c branches/header-work/tools/tools.rbuild
Modified: branches/header-work/tools/hpp/hpp.c URL: http://svn.reactos.org/svn/reactos/branches/header-work/tools/hpp/hpp.c?rev=... ============================================================================== --- branches/header-work/tools/hpp/hpp.c [iso-8859-1] (original) +++ branches/header-work/tools/hpp/hpp.c [iso-8859-1] Thu Mar 11 00:37:47 2010 @@ -11,6 +11,8 @@ #include <stdarg.h> #include <string.h> #include <ctype.h> + +//#define DBG 1
#if DBG #define trace printf @@ -70,24 +72,40 @@ { FILE* file; void* pFileData = NULL; + int iFileSize; + + trace("Loading file...");
file = fopen(pszFileName, "rb"); - if (file != NULL) + if (!file) { - fseek(file, 0L, SEEK_END); - *pFileSize = ftell(file); - fseek(file, 0L, SEEK_SET); - pFileData = malloc(*pFileSize); - if (pFileData != NULL) - { - if (*pFileSize != fread(pFileData, 1, *pFileSize, file)) - { - free(pFileData); - pFileData = NULL; - } - } - fclose(file); + trace("Could not open file\n"); + return NULL; } + + fseek(file, 0L, SEEK_END); + iFileSize = ftell(file); + fseek(file, 0L, SEEK_SET); + *pFileSize = iFileSize; + trace("ok. Size is %d\n", iFileSize); + + pFileData = malloc(iFileSize + 1); + + if (pFileData != NULL) + { + if (iFileSize != fread(pFileData, 1, iFileSize, file)) + { + free(pFileData); + pFileData = NULL; + } + } + else + { + trace("Could not allocate memory for file\n"); + } + + fclose(file); + return pFileData; }
@@ -452,6 +470,9 @@
/* Restore the global file name */ gpszCurFile = pszInFile; + + /* Restore the zeroed character */ + *p2 = ')';
if (ret == -1) { @@ -481,6 +502,8 @@ /* Free the file data */ free(pInputData);
+ trace("Done with file.\n\n"); + return 0; }
@@ -494,7 +517,7 @@
if (argc != 3) { - error("Usage: hc <inputfile> <outputfile>\n"); + error("Usage: hpp <inputfile> <outputfile>\n"); exit(1); }
Modified: branches/header-work/tools/tools.rbuild URL: http://svn.reactos.org/svn/reactos/branches/header-work/tools/tools.rbuild?r... ============================================================================== --- branches/header-work/tools/tools.rbuild [iso-8859-1] (original) +++ branches/header-work/tools/tools.rbuild [iso-8859-1] Thu Mar 11 00:37:47 2010 @@ -6,6 +6,9 @@ </directory> <directory name="cdmake"> <xi:include href="cdmake/cdmake.rbuild" /> +</directory> +<directory name="hpp"> + <xi:include href="hpp/hpp.rbuild" /> </directory> <directory name="kbdtool"> <xi:include href="kbdtool/kbdtool.rbuild" />