mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
uppsrc: MemoryAlloc instead of new[]
git-svn-id: svn://ultimatepp.org/upp/trunk@13389 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
48eb19fff1
commit
5656bb4d01
5 changed files with 16 additions and 16 deletions
|
|
@ -19,8 +19,8 @@ void BlockStream::SetBufferSize(dword size)
|
|||
pagesize = 1 << n;
|
||||
pagemask = (uint64)-1 << n;
|
||||
if(buffer)
|
||||
delete[] buffer;
|
||||
buffer = new byte[pagesize];
|
||||
MemoryFree(buffer);
|
||||
buffer = (byte *)MemoryAlloc(pagesize);
|
||||
pos = 0;
|
||||
ptr = rdlim = wrlim = buffer;
|
||||
pagepos = -1;
|
||||
|
|
@ -36,7 +36,7 @@ BlockStream::BlockStream()
|
|||
BlockStream::~BlockStream()
|
||||
{
|
||||
if(buffer)
|
||||
delete[] buffer;
|
||||
MemoryFree(buffer);
|
||||
}
|
||||
|
||||
int64 BlockStream::GetSize() const {
|
||||
|
|
|
|||
|
|
@ -1147,14 +1147,14 @@ void CompareStream::_Put(int w) {
|
|||
OutStream::OutStream()
|
||||
{
|
||||
const int bsz = 64 * 1024;
|
||||
h = new byte[bsz];
|
||||
h = (byte *)MemoryAlloc(bsz);
|
||||
buffer = ptr = h;
|
||||
wrlim = h + bsz;
|
||||
}
|
||||
|
||||
OutStream::~OutStream()
|
||||
{ // Note: cannot call Close here !
|
||||
delete[] h;
|
||||
MemoryFree(h);
|
||||
}
|
||||
|
||||
void OutStream::_Put(int w)
|
||||
|
|
|
|||
|
|
@ -672,7 +672,7 @@ String Array<T>::ToString() const
|
|||
template <class T>
|
||||
void BiVector<T>::ReAlloc(int newalloc) {
|
||||
ASSERT(items <= newalloc && items >= 0);
|
||||
T *newvector = newalloc ? (T *) new byte[newalloc * sizeof(T)] : NULL;
|
||||
T *newvector = newalloc ? (T *) MemoryAlloc(newalloc * sizeof(T)) : NULL;
|
||||
if(items) {
|
||||
int end = start + items;
|
||||
if(end <= alloc)
|
||||
|
|
@ -681,7 +681,7 @@ void BiVector<T>::ReAlloc(int newalloc) {
|
|||
memcpy((void *)newvector, (void *)(vector + start), (alloc - start) * sizeof(T));
|
||||
memcpy((void *)(newvector + alloc - start), (void *)vector, (end - alloc) * sizeof(T));
|
||||
}
|
||||
delete[] (byte *)vector;
|
||||
MemoryFree(vector);
|
||||
}
|
||||
vector = newvector;
|
||||
alloc = newalloc;
|
||||
|
|
@ -745,7 +745,7 @@ void BiVector<T>::Free() {
|
|||
Destroy(vector + start, vector + alloc);
|
||||
Destroy(vector, vector + end - alloc);
|
||||
}
|
||||
delete[] (byte *)vector;
|
||||
MemoryFree(vector);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ namespace Upp {
|
|||
|
||||
static voidpf zalloc_new(voidpf opaque, uInt items, uInt size)
|
||||
{
|
||||
return new byte[items * size];
|
||||
return MemoryAlloc(items * size);
|
||||
}
|
||||
|
||||
static void zfree_new(voidpf opaque, voidpf address)
|
||||
{
|
||||
delete[] (byte *)address;
|
||||
MemoryFree(address);
|
||||
}
|
||||
|
||||
enum
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ class ClippingLine : NoCopy {
|
|||
byte *data;
|
||||
|
||||
public:
|
||||
void Clear() { if(!IsFull()) delete[] data; data = NULL; }
|
||||
void Set(const byte *s, int len) { data = new byte[len]; memcpy(data, s, len); }
|
||||
void SetFull() { ASSERT(!data); data = (byte *)1; }
|
||||
void Clear() { if(!IsFull()) MemoryFree(data); data = NULL; }
|
||||
void Set(const byte *s, int len) { data = (byte *)MemoryAlloc(len); memcpy(data, s, len); }
|
||||
void SetFull() { ASSERT(!data); data = (byte *)1; }
|
||||
|
||||
bool IsEmpty() const { return !data; }
|
||||
bool IsFull() const { return data == (byte *)1; }
|
||||
operator const byte*() const { return data; }
|
||||
bool IsEmpty() const { return !data; }
|
||||
bool IsFull() const { return data == (byte *)1; }
|
||||
operator const byte*() const { return data; }
|
||||
|
||||
ClippingLine() { data = NULL; }
|
||||
~ClippingLine() { Clear(); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue