Jim Park's Unicode NSIS merging - Step 1 : switch to TCHARs where relevant.
Compiler output is identical before & after this step git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/branches/wizou@6036 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
4e48722b63
commit
752d7d239a
209 changed files with 9698 additions and 7658 deletions
|
@ -12,6 +12,8 @@
|
|||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty.
|
||||
*
|
||||
* Unicode support and Doxygen comments by Jim Park -- 07/31/2007
|
||||
*/
|
||||
|
||||
#include "growbuf.h"
|
||||
|
@ -20,12 +22,16 @@
|
|||
#include <cstring> // for memcpy
|
||||
#include <cstdio> // for f*
|
||||
#include <algorithm> // for std::min
|
||||
#include "tchar.h"
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Default constructor
|
||||
GrowBuf::GrowBuf() { m_alloc=m_used=m_zero=0; m_s=NULL; m_bs=32768; }
|
||||
|
||||
// Destructor
|
||||
GrowBuf::~GrowBuf() { free(m_s); }
|
||||
|
||||
void GrowBuf::set_zeroing(int zero) { m_zero=zero; }
|
||||
|
@ -34,18 +40,22 @@ int GrowBuf::add(const void *data, int len)
|
|||
{
|
||||
if (len<=0) return 0;
|
||||
resize(m_used+len);
|
||||
memcpy((char*)m_s+m_used-len,data,len);
|
||||
memcpy((BYTE*)m_s+m_used-len,data,len);
|
||||
return m_used-len;
|
||||
}
|
||||
|
||||
void GrowBuf::resize(int newlen)
|
||||
{
|
||||
int os=m_alloc;
|
||||
int ou=m_used;
|
||||
int os=m_alloc; // old size
|
||||
int ou=m_used; // old used
|
||||
m_used=newlen;
|
||||
if (newlen > m_alloc)
|
||||
{
|
||||
void *n;
|
||||
|
||||
// Jim Park: Not sure why we don't just add m_bs. Multiplying by 2
|
||||
// makes m_bs meaningless after a few resizes. So TinyGrowBuf
|
||||
// isn't very tiny.
|
||||
m_alloc = newlen*2 + m_bs;
|
||||
n = realloc(m_s, m_alloc);
|
||||
if (!n)
|
||||
|
@ -54,7 +64,7 @@ void GrowBuf::resize(int newlen)
|
|||
extern int g_display_errors;
|
||||
if (g_display_errors)
|
||||
{
|
||||
fprintf(g_output,"\nack! realloc(%d) failed, trying malloc(%d)!\n",m_alloc,newlen);
|
||||
_ftprintf(g_output,_T("\nack! realloc(%d) failed, trying malloc(%d)!\n"),m_alloc,newlen);
|
||||
fflush(g_output);
|
||||
}
|
||||
m_alloc=newlen; // try to malloc the minimum needed
|
||||
|
@ -64,7 +74,7 @@ void GrowBuf::resize(int newlen)
|
|||
extern void quit();
|
||||
if (g_display_errors)
|
||||
{
|
||||
fprintf(g_output,"\nInternal compiler error #12345: GrowBuf realloc/malloc(%d) failed.\n",m_alloc);
|
||||
_ftprintf(g_output,_T("\nInternal compiler error #12345: GrowBuf realloc/malloc(%d) failed.\n"),m_alloc);
|
||||
fflush(g_output);
|
||||
}
|
||||
quit();
|
||||
|
@ -74,9 +84,13 @@ void GrowBuf::resize(int newlen)
|
|||
}
|
||||
m_s=n;
|
||||
}
|
||||
|
||||
// Zero out the new buffer area
|
||||
if (m_zero && m_used > ou)
|
||||
memset((char*)m_s + ou, 0, m_used - ou);
|
||||
if (!m_used && m_alloc > 2*m_bs) // only free if you resize to 0 and we're > 64k
|
||||
memset((BYTE*)m_s + ou, 0, m_used - ou);
|
||||
|
||||
if (!m_used && m_alloc > 2*m_bs) // only free if you resize to 0 and we're > 64k or
|
||||
// 2K in the case of TinyGrowBuf
|
||||
{
|
||||
m_alloc=0;
|
||||
free(m_s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue