* Basic System::Call support when compiling with 64-bit MinGW/GCC toolchain
* Win64 fixes git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6607 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
757d16f937
commit
286edd20c4
41 changed files with 335 additions and 232 deletions
|
@ -30,36 +30,37 @@
|
|||
using namespace std;
|
||||
|
||||
// Default constructor
|
||||
GrowBuf::GrowBuf() { m_alloc=m_used=m_zero=0; m_s=NULL; m_bs=32768; }
|
||||
GrowBuf::GrowBuf() { m_alloc=m_used=0, m_zero=false, m_s=NULL, m_bs=32768; }
|
||||
|
||||
// Destructor
|
||||
GrowBuf::~GrowBuf() { free(m_s); }
|
||||
|
||||
void GrowBuf::set_zeroing(int zero) { m_zero=zero; }
|
||||
void GrowBuf::set_zeroing(bool zero) { m_zero=zero; }
|
||||
|
||||
int GrowBuf::add(const void *data, int len)
|
||||
GrowBuf::size_type GrowBuf::add(const void *data, GrowBuf::size_type len)
|
||||
{
|
||||
if (len<=0) return 0;
|
||||
if (len<=0) return 0; // BUGBUG: Why is this returning 0? It should return m_used?
|
||||
resize(m_used+len);
|
||||
memcpy((BYTE*)m_s+m_used-len,data,len);
|
||||
return m_used-len;
|
||||
}
|
||||
|
||||
void GrowBuf::resize(int newlen)
|
||||
void GrowBuf::resize(GrowBuf::size_type newlen)
|
||||
{
|
||||
int os=m_alloc; // old size
|
||||
int ou=m_used; // old used
|
||||
const size_type orgalloc=m_alloc;
|
||||
const size_type orgused=m_used;
|
||||
|
||||
m_used=newlen;
|
||||
if (newlen > m_alloc)
|
||||
{
|
||||
void *n;
|
||||
void *newstor;
|
||||
|
||||
// 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)
|
||||
newstor = realloc(m_s, m_alloc);
|
||||
if (!newstor)
|
||||
{
|
||||
extern int g_display_errors;
|
||||
if (g_display_errors)
|
||||
|
@ -67,8 +68,8 @@ void GrowBuf::resize(int newlen)
|
|||
PrintColorFmtMsg_ERR(_T("\nack! realloc(%d) failed, trying malloc(%d)!\n"),m_alloc,newlen);
|
||||
}
|
||||
m_alloc=newlen; // try to malloc the minimum needed
|
||||
n=malloc(m_alloc);
|
||||
if (!n)
|
||||
newstor=malloc(m_alloc);
|
||||
if (!newstor)
|
||||
{
|
||||
extern void quit();
|
||||
if (g_display_errors)
|
||||
|
@ -77,15 +78,15 @@ void GrowBuf::resize(int newlen)
|
|||
}
|
||||
quit();
|
||||
}
|
||||
memcpy(n,m_s,min(newlen,os));
|
||||
memcpy(newstor,m_s,min(newlen,orgalloc));
|
||||
free(m_s);
|
||||
}
|
||||
m_s=n;
|
||||
m_s=newstor;
|
||||
}
|
||||
|
||||
// Zero out the new buffer area
|
||||
if (m_zero && m_used > ou)
|
||||
memset((BYTE*)m_s + ou, 0, m_used - ou);
|
||||
if (m_zero && m_used > orgused)
|
||||
memset((BYTE*)m_s + orgused, 0, m_used - orgused);
|
||||
|
||||
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
|
||||
|
@ -96,7 +97,7 @@ void GrowBuf::resize(int newlen)
|
|||
}
|
||||
}
|
||||
|
||||
int GrowBuf::getlen() const { return m_used; }
|
||||
GrowBuf::size_type GrowBuf::getlen() const { return m_used; }
|
||||
void *GrowBuf::get() const { return m_s; }
|
||||
|
||||
void GrowBuf::swap(GrowBuf&other)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue