There are three functions

void operator delete(void * hPointer); void operator delete(void * hPointer, size_t ulSize); void operator delete[](void * hPointer, size_t ulSize); 

which call the same code. For example (and for example only):

 { hPointer=nullptr; return; } 

It would be possible to copy the code for each function, but it would be better to use a system of aliases. That is, for any delete , the same function must be called. The use of preprocessor directives is excluded, because the function signatures are different.

  • one
    Why "copy code"? Let the second and third cause the first - almost no copying of the code. - AnT
  • @AnT does not want to compile. Error "delete-incomplete" - Adokenai
  • Is it like this? Without the code it is impossible to say what you have there for delete incomplete. - AnT
  • Firstly, if your functions will obviously consist simply of calling kmfree , then why make a garden? This is the repetition of the code, which will not get rid of. Secondly, where is the "delete incomplete" here? - AnT
  • @AnT yadi.sk/i/40PqPEo7Na3ujQ - Adokenai

1 answer 1

Just call the first function from the rest, and there will be [almost] no repetition of the code.

 void operator delete(void * hPointer) { // Общая реализация } void operator delete(void * hPointer, size_t ulSize) { operator delete(hPointer); } void operator delete[](void * hPointer, size_t ulSize) { operator delete(hPointer); } 

Just do it right, i.e. with the name of the function. And the name is operator delete . I suspect your comment that you tried to delete hPointer in the second and third functions, which of course is not at all.