I found an old package online that I'd like to use. One of the header files includes the following lines:
#include "gcc_version.h"
#if GCC_VERSION>=3002
#define malloc_alloc __single_client_alloc
#include <ext/algorithm>
#include <ext/memory>
#else
#define __gnu_cxx std
#endif
My GCC_VERSION is 7003, and __single_client_alloc
is apparently long gone. single_client_alloc
existed for a while as well, but I can't figure out if it still exists or, if it does, what header it lives in.
It looks like the only places where this is actually used are the following scary-looking functions:
void* operator new(size_t s) { return std::malloc_alloc::allocate(s); }
void operator delete(void* p) { std::malloc_alloc::deallocate(p,sizeof(classname)); }
//and in another class
void* operator new(size_t, size_t n) { return std::malloc_alloc::allocate(total_size(n)); }
void operator delete(void* p) { std::malloc_alloc::deallocate((otherclassname*)p,total_size(reinterpret_cast<otherclassname*>(p)->size));}
Is it safe to just comment them and revert to the default new
and delete
behavior? Or are these doing something beyond making the code more memory-efficient, in which case I need an actual fix?
Basically, is there a fix to this code so that it will work under recent GCC versions?