mirror of
https://github.com/corda/corda.git
synced 2025-06-01 23:20:54 +00:00
reduce Allocator interface
This commit is contained in:
parent
2d0ac3ac17
commit
fa1e3d74c0
@ -58,10 +58,10 @@ class Heap : public avian::util::Allocator {
|
|||||||
unsigned footprint,
|
unsigned footprint,
|
||||||
int pendingAllocation) = 0;
|
int pendingAllocation) = 0;
|
||||||
virtual unsigned fixedFootprint(unsigned sizeInWords, bool objectMask) = 0;
|
virtual unsigned fixedFootprint(unsigned sizeInWords, bool objectMask) = 0;
|
||||||
virtual void* allocateFixed(avian::util::Allocator* allocator,
|
virtual void* allocateFixed(avian::util::Alloc* allocator,
|
||||||
unsigned sizeInWords,
|
unsigned sizeInWords,
|
||||||
bool objectMask) = 0;
|
bool objectMask) = 0;
|
||||||
virtual void* allocateImmortalFixed(avian::util::Allocator* allocator,
|
virtual void* allocateImmortalFixed(avian::util::Alloc* allocator,
|
||||||
unsigned sizeInWords,
|
unsigned sizeInWords,
|
||||||
bool objectMask) = 0;
|
bool objectMask) = 0;
|
||||||
virtual void mark(void* p, unsigned offset, unsigned count) = 0;
|
virtual void mark(void* p, unsigned offset, unsigned count) = 0;
|
||||||
|
@ -130,7 +130,7 @@ class System : public avian::util::Aborter {
|
|||||||
virtual Status load(Library**, const char* name) = 0;
|
virtual Status load(Library**, const char* name) = 0;
|
||||||
virtual char pathSeparator() = 0;
|
virtual char pathSeparator() = 0;
|
||||||
virtual char fileSeparator() = 0;
|
virtual char fileSeparator() = 0;
|
||||||
virtual const char* toAbsolutePath(avian::util::Allocator* allocator,
|
virtual const char* toAbsolutePath(avian::util::AllocOnly* allocator,
|
||||||
const char* name) = 0;
|
const char* name) = 0;
|
||||||
virtual int64_t now() = 0;
|
virtual int64_t now() = 0;
|
||||||
virtual void yield() = 0;
|
virtual void yield() = 0;
|
||||||
|
@ -21,10 +21,14 @@ class AllocOnly {
|
|||||||
virtual void* allocate(size_t size) = 0;
|
virtual void* allocate(size_t size) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Allocator : public AllocOnly {
|
class Alloc : public AllocOnly {
|
||||||
|
public:
|
||||||
|
virtual void free(const void* p, size_t size) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Allocator : public Alloc {
|
||||||
public:
|
public:
|
||||||
virtual void* tryAllocate(size_t size) = 0;
|
virtual void* tryAllocate(size_t size) = 0;
|
||||||
virtual void free(const void* p, size_t size) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
|
@ -20,7 +20,7 @@ namespace util {
|
|||||||
|
|
||||||
// An Allocator that allocates, bump-pointer style, out of a pre-defined chunk
|
// An Allocator that allocates, bump-pointer style, out of a pre-defined chunk
|
||||||
// of memory.
|
// of memory.
|
||||||
class FixedAllocator : public Allocator {
|
class FixedAllocator : public Alloc {
|
||||||
public:
|
public:
|
||||||
FixedAllocator(Aborter* a, Slice<uint8_t> memory);
|
FixedAllocator(Aborter* a, Slice<uint8_t> memory);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
|
|
||||||
inline const char* append(avian::util::Allocator* allocator,
|
inline const char* append(avian::util::AllocOnly* allocator,
|
||||||
const char* a,
|
const char* a,
|
||||||
const char* b,
|
const char* b,
|
||||||
const char* c)
|
const char* c)
|
||||||
@ -31,7 +31,7 @@ inline const char* append(avian::util::Allocator* allocator,
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* append(avian::util::Allocator* allocator,
|
inline const char* append(avian::util::AllocOnly* allocator,
|
||||||
const char* a,
|
const char* a,
|
||||||
const char* b)
|
const char* b)
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ inline const char* append(avian::util::Allocator* allocator,
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* copy(avian::util::Allocator* allocator, const char* a)
|
inline const char* copy(avian::util::AllocOnly* allocator, const char* a)
|
||||||
{
|
{
|
||||||
unsigned al = strlen(a);
|
unsigned al = strlen(a);
|
||||||
char* p = static_cast<char*>(allocator->allocate(al + 1));
|
char* p = static_cast<char*>(allocator->allocate(al + 1));
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
namespace avian {
|
namespace avian {
|
||||||
namespace util {
|
namespace util {
|
||||||
class Allocator;
|
class Alloc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,12 +202,12 @@ class Finder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
AVIAN_EXPORT Finder* makeFinder(System* s,
|
AVIAN_EXPORT Finder* makeFinder(System* s,
|
||||||
avian::util::Allocator* a,
|
avian::util::Alloc* a,
|
||||||
const char* path,
|
const char* path,
|
||||||
const char* bootLibrary);
|
const char* bootLibrary);
|
||||||
|
|
||||||
Finder* makeFinder(System* s,
|
Finder* makeFinder(System* s,
|
||||||
avian::util::Allocator* a,
|
avian::util::Alloc* a,
|
||||||
const uint8_t* jarData,
|
const uint8_t* jarData,
|
||||||
unsigned jarLength);
|
unsigned jarLength);
|
||||||
|
|
||||||
|
@ -1596,7 +1596,7 @@ inline bool ensure(Thread* t, unsigned sizeInBytes)
|
|||||||
object allocate2(Thread* t, unsigned sizeInBytes, bool objectMask);
|
object allocate2(Thread* t, unsigned sizeInBytes, bool objectMask);
|
||||||
|
|
||||||
object allocate3(Thread* t,
|
object allocate3(Thread* t,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
Machine::AllocationType type,
|
Machine::AllocationType type,
|
||||||
unsigned sizeInBytes,
|
unsigned sizeInBytes,
|
||||||
bool objectMask);
|
bool objectMask);
|
||||||
|
@ -1264,7 +1264,7 @@ class Context {
|
|||||||
TraceElement* traceLog;
|
TraceElement* traceLog;
|
||||||
Slice<uint16_t> visitTable;
|
Slice<uint16_t> visitTable;
|
||||||
Slice<uintptr_t> rootTable;
|
Slice<uintptr_t> rootTable;
|
||||||
Allocator* executableAllocator;
|
Alloc* executableAllocator;
|
||||||
void* executableStart;
|
void* executableStart;
|
||||||
unsigned executableSize;
|
unsigned executableSize;
|
||||||
unsigned objectPoolCount;
|
unsigned objectPoolCount;
|
||||||
|
@ -56,7 +56,7 @@ class DirectoryElement : public Element {
|
|||||||
public:
|
public:
|
||||||
class Iterator : public Element::Iterator {
|
class Iterator : public Element::Iterator {
|
||||||
public:
|
public:
|
||||||
Iterator(System* s, Allocator* allocator, const char* name, unsigned skip)
|
Iterator(System* s, Alloc* allocator, const char* name, unsigned skip)
|
||||||
: s(s),
|
: s(s),
|
||||||
allocator(allocator),
|
allocator(allocator),
|
||||||
name(name),
|
name(name),
|
||||||
@ -113,7 +113,7 @@ class DirectoryElement : public Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
const char* name;
|
const char* name;
|
||||||
unsigned skip;
|
unsigned skip;
|
||||||
System::Directory* directory;
|
System::Directory* directory;
|
||||||
@ -121,7 +121,7 @@ class DirectoryElement : public Element {
|
|||||||
Iterator* it;
|
Iterator* it;
|
||||||
};
|
};
|
||||||
|
|
||||||
DirectoryElement(System* s, Allocator* allocator, const char* name)
|
DirectoryElement(System* s, Alloc* allocator, const char* name)
|
||||||
: s(s),
|
: s(s),
|
||||||
allocator(allocator),
|
allocator(allocator),
|
||||||
originalName(name),
|
originalName(name),
|
||||||
@ -188,7 +188,7 @@ class DirectoryElement : public Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
const char* originalName;
|
const char* originalName;
|
||||||
const char* name;
|
const char* name;
|
||||||
const char* urlPrefix_;
|
const char* urlPrefix_;
|
||||||
@ -198,7 +198,7 @@ class DirectoryElement : public Element {
|
|||||||
class PointerRegion : public System::Region {
|
class PointerRegion : public System::Region {
|
||||||
public:
|
public:
|
||||||
PointerRegion(System* s,
|
PointerRegion(System* s,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const uint8_t* start,
|
const uint8_t* start,
|
||||||
size_t length,
|
size_t length,
|
||||||
bool freePointer = false)
|
bool freePointer = false)
|
||||||
@ -229,7 +229,7 @@ class PointerRegion : public System::Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
const uint8_t* start_;
|
const uint8_t* start_;
|
||||||
size_t length_;
|
size_t length_;
|
||||||
bool freePointer;
|
bool freePointer;
|
||||||
@ -237,7 +237,7 @@ class PointerRegion : public System::Region {
|
|||||||
|
|
||||||
class DataRegion : public System::Region {
|
class DataRegion : public System::Region {
|
||||||
public:
|
public:
|
||||||
DataRegion(System* s, Allocator* allocator, size_t length)
|
DataRegion(System* s, Alloc* allocator, size_t length)
|
||||||
: s(s), allocator(allocator), length_(length)
|
: s(s), allocator(allocator), length_(length)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ class DataRegion : public System::Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
size_t length_;
|
size_t length_;
|
||||||
uint8_t data[0];
|
uint8_t data[0];
|
||||||
};
|
};
|
||||||
@ -277,7 +277,7 @@ class JarIndex {
|
|||||||
const uint8_t* entry;
|
const uint8_t* entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
JarIndex(System* s, Allocator* allocator, unsigned capacity)
|
JarIndex(System* s, Alloc* allocator, unsigned capacity)
|
||||||
: s(s),
|
: s(s),
|
||||||
allocator(allocator),
|
allocator(allocator),
|
||||||
capacity(capacity),
|
capacity(capacity),
|
||||||
@ -288,14 +288,14 @@ class JarIndex {
|
|||||||
memset(table, 0, sizeof(List<Entry>*) * capacity);
|
memset(table, 0, sizeof(List<Entry>*) * capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JarIndex* make(System* s, Allocator* allocator, unsigned capacity)
|
static JarIndex* make(System* s, Alloc* allocator, unsigned capacity)
|
||||||
{
|
{
|
||||||
return new (allocator->allocate(sizeof(JarIndex)
|
return new (allocator->allocate(sizeof(JarIndex)
|
||||||
+ (sizeof(List<Entry>*) * capacity)))
|
+ (sizeof(List<Entry>*) * capacity)))
|
||||||
JarIndex(s, allocator, capacity);
|
JarIndex(s, allocator, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JarIndex* open(System* s, Allocator* allocator, System::Region* region)
|
static JarIndex* open(System* s, Alloc* allocator, System::Region* region)
|
||||||
{
|
{
|
||||||
JarIndex* index = make(s, allocator, 32);
|
JarIndex* index = make(s, allocator, 32);
|
||||||
|
|
||||||
@ -438,7 +438,7 @@ class JarIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
unsigned capacity;
|
unsigned capacity;
|
||||||
unsigned position;
|
unsigned position;
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ class JarElement : public Element {
|
|||||||
public:
|
public:
|
||||||
class Iterator : public Element::Iterator {
|
class Iterator : public Element::Iterator {
|
||||||
public:
|
public:
|
||||||
Iterator(System* s, Allocator* allocator, JarIndex* index)
|
Iterator(System* s, Alloc* allocator, JarIndex* index)
|
||||||
: s(s), allocator(allocator), index(index), position(0)
|
: s(s), allocator(allocator), index(index), position(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -472,13 +472,13 @@ class JarElement : public Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
JarIndex* index;
|
JarIndex* index;
|
||||||
unsigned position;
|
unsigned position;
|
||||||
};
|
};
|
||||||
|
|
||||||
JarElement(System* s,
|
JarElement(System* s,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const char* name,
|
const char* name,
|
||||||
bool canonicalizePath = true)
|
bool canonicalizePath = true)
|
||||||
: s(s),
|
: s(s),
|
||||||
@ -495,7 +495,7 @@ class JarElement : public Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JarElement(System* s,
|
JarElement(System* s,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const uint8_t* jarData,
|
const uint8_t* jarData,
|
||||||
unsigned jarLength)
|
unsigned jarLength)
|
||||||
: s(s),
|
: s(s),
|
||||||
@ -599,7 +599,7 @@ class JarElement : public Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
const char* originalName;
|
const char* originalName;
|
||||||
const char* name;
|
const char* name;
|
||||||
const char* urlPrefix_;
|
const char* urlPrefix_;
|
||||||
@ -611,7 +611,7 @@ class JarElement : public Element {
|
|||||||
class BuiltinElement : public JarElement {
|
class BuiltinElement : public JarElement {
|
||||||
public:
|
public:
|
||||||
BuiltinElement(System* s,
|
BuiltinElement(System* s,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const char* name,
|
const char* name,
|
||||||
const char* libraryName)
|
const char* libraryName)
|
||||||
: JarElement(s, allocator, name, false),
|
: JarElement(s, allocator, name, false),
|
||||||
@ -711,7 +711,7 @@ unsigned baseName(const char* name, char fileSeparator)
|
|||||||
void add(System* s,
|
void add(System* s,
|
||||||
Element** first,
|
Element** first,
|
||||||
Element** last,
|
Element** last,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const char* name,
|
const char* name,
|
||||||
unsigned nameLength,
|
unsigned nameLength,
|
||||||
const char* bootLibrary);
|
const char* bootLibrary);
|
||||||
@ -719,7 +719,7 @@ void add(System* s,
|
|||||||
void addTokens(System* s,
|
void addTokens(System* s,
|
||||||
Element** first,
|
Element** first,
|
||||||
Element** last,
|
Element** last,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const char* jarName,
|
const char* jarName,
|
||||||
unsigned jarNameBase,
|
unsigned jarNameBase,
|
||||||
const char* tokens,
|
const char* tokens,
|
||||||
@ -756,7 +756,7 @@ bool continuationLine(const uint8_t* base,
|
|||||||
void addJar(System* s,
|
void addJar(System* s,
|
||||||
Element** first,
|
Element** first,
|
||||||
Element** last,
|
Element** last,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const char* name,
|
const char* name,
|
||||||
const char* bootLibrary)
|
const char* bootLibrary)
|
||||||
{
|
{
|
||||||
@ -852,7 +852,7 @@ void addJar(System* s,
|
|||||||
void add(System* s,
|
void add(System* s,
|
||||||
Element** first,
|
Element** first,
|
||||||
Element** last,
|
Element** last,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const char* token,
|
const char* token,
|
||||||
unsigned tokenLength,
|
unsigned tokenLength,
|
||||||
const char* bootLibrary)
|
const char* bootLibrary)
|
||||||
@ -904,7 +904,7 @@ void add(System* s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Element* parsePath(System* s,
|
Element* parsePath(System* s,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const char* path,
|
const char* path,
|
||||||
const char* bootLibrary)
|
const char* bootLibrary)
|
||||||
{
|
{
|
||||||
@ -921,7 +921,7 @@ Element* parsePath(System* s,
|
|||||||
|
|
||||||
class MyIterator : public Finder::IteratorImp {
|
class MyIterator : public Finder::IteratorImp {
|
||||||
public:
|
public:
|
||||||
MyIterator(System* s, Allocator* allocator, Element* path)
|
MyIterator(System* s, Alloc* allocator, Element* path)
|
||||||
: s(s),
|
: s(s),
|
||||||
allocator(allocator),
|
allocator(allocator),
|
||||||
e(path ? path->next : 0),
|
e(path ? path->next : 0),
|
||||||
@ -956,7 +956,7 @@ class MyIterator : public Finder::IteratorImp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
Element* e;
|
Element* e;
|
||||||
Element::Iterator* it;
|
Element::Iterator* it;
|
||||||
};
|
};
|
||||||
@ -964,7 +964,7 @@ class MyIterator : public Finder::IteratorImp {
|
|||||||
class MyFinder : public Finder {
|
class MyFinder : public Finder {
|
||||||
public:
|
public:
|
||||||
MyFinder(System* system,
|
MyFinder(System* system,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const char* path,
|
const char* path,
|
||||||
const char* bootLibrary)
|
const char* bootLibrary)
|
||||||
: system(system),
|
: system(system),
|
||||||
@ -975,7 +975,7 @@ class MyFinder : public Finder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MyFinder(System* system,
|
MyFinder(System* system,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
const uint8_t* jarData,
|
const uint8_t* jarData,
|
||||||
unsigned jarLength)
|
unsigned jarLength)
|
||||||
: system(system),
|
: system(system),
|
||||||
@ -1071,7 +1071,7 @@ class MyFinder : public Finder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* system;
|
System* system;
|
||||||
Allocator* allocator;
|
Alloc* allocator;
|
||||||
Element* path_;
|
Element* path_;
|
||||||
const char* pathString;
|
const char* pathString;
|
||||||
};
|
};
|
||||||
@ -1081,7 +1081,7 @@ class MyFinder : public Finder {
|
|||||||
namespace vm {
|
namespace vm {
|
||||||
|
|
||||||
AVIAN_EXPORT Finder* makeFinder(System* s,
|
AVIAN_EXPORT Finder* makeFinder(System* s,
|
||||||
Allocator* a,
|
Alloc* a,
|
||||||
const char* path,
|
const char* path,
|
||||||
const char* bootLibrary)
|
const char* bootLibrary)
|
||||||
{
|
{
|
||||||
@ -1089,7 +1089,7 @@ AVIAN_EXPORT Finder* makeFinder(System* s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Finder* makeFinder(System* s,
|
Finder* makeFinder(System* s,
|
||||||
Allocator* a,
|
Alloc* a,
|
||||||
const uint8_t* jarData,
|
const uint8_t* jarData,
|
||||||
unsigned jarLength)
|
unsigned jarLength)
|
||||||
{
|
{
|
||||||
|
@ -1994,7 +1994,7 @@ class MyHeap : public Heap {
|
|||||||
return Fixie::totalSize(sizeInWords, objectMask);
|
return Fixie::totalSize(sizeInWords, objectMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* allocateFixed(Allocator* allocator,
|
void* allocateFixed(Alloc* allocator,
|
||||||
unsigned sizeInWords,
|
unsigned sizeInWords,
|
||||||
bool objectMask,
|
bool objectMask,
|
||||||
Fixie** handle,
|
Fixie** handle,
|
||||||
@ -2011,7 +2011,7 @@ class MyHeap : public Heap {
|
|||||||
->body();
|
->body();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void* allocateFixed(Allocator* allocator,
|
virtual void* allocateFixed(Alloc* allocator,
|
||||||
unsigned sizeInWords,
|
unsigned sizeInWords,
|
||||||
bool objectMask)
|
bool objectMask)
|
||||||
{
|
{
|
||||||
@ -2019,7 +2019,7 @@ class MyHeap : public Heap {
|
|||||||
allocator, sizeInWords, objectMask, &(c.fixies), false);
|
allocator, sizeInWords, objectMask, &(c.fixies), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void* allocateImmortalFixed(Allocator* allocator,
|
virtual void* allocateImmortalFixed(Alloc* allocator,
|
||||||
unsigned sizeInWords,
|
unsigned sizeInWords,
|
||||||
bool objectMask)
|
bool objectMask)
|
||||||
{
|
{
|
||||||
|
@ -4175,7 +4175,7 @@ object allocate2(Thread* t, unsigned sizeInBytes, bool objectMask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
object allocate3(Thread* t,
|
object allocate3(Thread* t,
|
||||||
Allocator* allocator,
|
Alloc* allocator,
|
||||||
Machine::AllocationType type,
|
Machine::AllocationType type,
|
||||||
unsigned sizeInBytes,
|
unsigned sizeInBytes,
|
||||||
bool objectMask)
|
bool objectMask)
|
||||||
|
@ -62,20 +62,15 @@ const char* mainClass(const char* jar)
|
|||||||
|
|
||||||
System* system = makeSystem();
|
System* system = makeSystem();
|
||||||
|
|
||||||
class MyAllocator : public avian::util::Allocator {
|
class MyAllocator : public avian::util::Alloc {
|
||||||
public:
|
public:
|
||||||
MyAllocator(System* s) : s(s)
|
MyAllocator(System* s) : s(s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void* tryAllocate(size_t size)
|
|
||||||
{
|
|
||||||
return s->tryAllocate(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void* allocate(size_t size)
|
virtual void* allocate(size_t size)
|
||||||
{
|
{
|
||||||
void* p = tryAllocate(size);
|
void* p = s->tryAllocate(size);
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
abort(s);
|
abort(s);
|
||||||
}
|
}
|
||||||
|
@ -856,7 +856,7 @@ class MySystem : public System {
|
|||||||
return SO_SUFFIX;
|
return SO_SUFFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char* toAbsolutePath(Allocator* allocator, const char* name)
|
virtual const char* toAbsolutePath(AllocOnly* allocator, const char* name)
|
||||||
{
|
{
|
||||||
if (name[0] == '/') {
|
if (name[0] == '/') {
|
||||||
return copy(allocator, name);
|
return copy(allocator, name);
|
||||||
|
@ -893,7 +893,7 @@ class MySystem : public System {
|
|||||||
return SO_SUFFIX;
|
return SO_SUFFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char* toAbsolutePath(avian::util::Allocator* allocator,
|
virtual const char* toAbsolutePath(avian::util::AllocOnly* allocator,
|
||||||
const char* name)
|
const char* name)
|
||||||
{
|
{
|
||||||
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
|
@ -1630,20 +1630,15 @@ int main(int ac, char** av)
|
|||||||
|
|
||||||
System* system = makeSystem();
|
System* system = makeSystem();
|
||||||
|
|
||||||
class MyAllocator : public avian::util::Allocator {
|
class MyAllocator : public avian::util::Alloc {
|
||||||
public:
|
public:
|
||||||
MyAllocator(System* s) : s(s)
|
MyAllocator(System* s) : s(s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void* tryAllocate(size_t size)
|
|
||||||
{
|
|
||||||
return s->tryAllocate(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void* allocate(size_t size)
|
virtual void* allocate(size_t size)
|
||||||
{
|
{
|
||||||
void* p = tryAllocate(size);
|
void* p = s->tryAllocate(size);
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
abort(s);
|
abort(s);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user