1

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?

Heshy
  • 382
  • 1
  • 10
  • Edit the package? – KamilCuk Apr 04 '19 at 19:21
  • @KamilCuk I was planning to, but I don't know what edits to make. Do you have any more specific suggestions? – Heshy Apr 04 '19 at 19:27
  • 1
    @Heshy - commenting and trying seems like a reasonable approach. You may try commenting the entire portion of the header and building using the default `new / delete` functions. Build with the `-g` option and then run the code through `valgrind` and see if it complains about allocate/free issues. – David C. Rankin Apr 04 '19 at 22:22

0 Answers0