2014-05-03 20:46:10 -04:00
|
|
|
__if_comp__ __C__ __simple_passthrough__ """
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
char* nullPtr = 0;
|
|
|
|
|
|
|
|
|
|
char* malloc(int size) {
|
|
|
|
|
char* memPtr = nullPtr;
|
|
|
|
|
__if_comp__ __C__ {
|
|
|
|
|
__simple_passthrough__ """
|
|
|
|
|
memPtr = malloc(size);
|
|
|
|
|
"""
|
|
|
|
|
}
|
|
|
|
|
return memPtr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void free(char* memPtr) {
|
|
|
|
|
__if_comp__ __C__ {
|
|
|
|
|
__simple_passthrough__ """
|
|
|
|
|
free(memPtr);
|
|
|
|
|
"""
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-19 20:00:35 -04:00
|
|
|
|
|
|
|
|
template <T> void free(T* memPtr) {
|
|
|
|
|
__if_comp__ __C__ {
|
|
|
|
|
__simple_passthrough__ """
|
|
|
|
|
free(memPtr);
|
|
|
|
|
"""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <T> int sizeof() {
|
|
|
|
|
int result = 0;
|
|
|
|
|
T testObj;
|
|
|
|
|
__if_comp__ __C__ {
|
|
|
|
|
__simple_passthrough__ """
|
|
|
|
|
result = sizeof(testObj);
|
|
|
|
|
"""
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <T> T* new(int count) {
|
|
|
|
|
return malloc( sizeof<T>() * count );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <T> T* new() {
|
|
|
|
|
return new<T>(1);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 01:57:50 -07:00
|
|
|
template <T> void delete(T* toDelete, int itemDestructCount) {
|
2014-07-02 01:18:27 -07:00
|
|
|
for (int i = 0; i < itemDestructCount; i++;)
|
2014-06-30 01:57:50 -07:00
|
|
|
toDelete[i].destruct();
|
2014-07-02 01:18:27 -07:00
|
|
|
delete<T>(toDelete);
|
2014-06-30 01:57:50 -07:00
|
|
|
}
|
|
|
|
|
|
2014-05-19 20:00:35 -04:00
|
|
|
template <T> void delete(T* toDelete) {
|
|
|
|
|
free<T>(toDelete);
|
|
|
|
|
}
|