moved memory debug function into extern "C" block.