]> git.sesse.net Git - freerainbowtables/blobdiff - Client Applications/rcracki_mt/MemoryPool.cpp
Fix O(n^2) behavior in ReadLinesFromFile().
[freerainbowtables] / Client Applications / rcracki_mt / MemoryPool.cpp
index f48961d895dfdceb07a28843378ebe5f023ee405..e5d540ad5c9f6de0161cf3c60efe76eb95a61e49 100644 (file)
@@ -5,10 +5,10 @@
  * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>\r
  * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>\r
  * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>\r
- * Copyright 2009, 2010 James Nobis <frt@quelrod.net>\r
+ * Copyright 2009, 2010, 2011 James Nobis <frt@quelrod.net>\r
  * Copyright 2010 uroskn\r
  *\r
- * This file is part of racrcki_mt.\r
+ * This file is part of rcracki_mt.\r
  *\r
  * rcracki_mt is free software: you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
@@ -33,11 +33,15 @@ CMemoryPool::CMemoryPool(unsigned int bytesSaved, bool bDebug, uint64 maxMem)
        m_nMemSize = 0;\r
        debug = bDebug;\r
 \r
-       uint64 nAvailPhys = GetAvailPhysMemorySize();\r
+       unsigned long nAvailPhys = GetAvailPhysMemorySize();\r
 \r
        if ( debug )\r
        {\r
-               printf( "Debug: nAvailPhys: %llu\n", nAvailPhys );\r
+               #if defined(_WIN32) && !defined(__GNUC__)\r
+                       printf( "Debug: nAvailPhys: %I64u\n", nAvailPhys );\r
+               #else\r
+                       printf( "Debug: nAvailPhys: %lu\n", nAvailPhys );\r
+               #endif\r
                printf( "Debug: bytesSaved: %d\n", bytesSaved );\r
        }\r
 \r
@@ -87,8 +91,8 @@ unsigned char* CMemoryPool::Allocate(unsigned int nFileLen, uint64& nAllocatedSi
        m_pMem = new (nothrow) unsigned char[nTargetSize];\r
        while (m_pMem == NULL && nTargetSize >= 32 * 1024 * 1024 )\r
        {\r
-          nTargetSize -= 16 * 1024 * 1024;\r
-          m_pMem = new (nothrow) unsigned char[nTargetSize];\r
+               nTargetSize -= 16 * 1024 * 1024;\r
+               m_pMem = new (nothrow) unsigned char[nTargetSize];\r
        }\r
 \r
        if (m_pMem != NULL)\r