fix C++ compiler buffer overflow for debug build
correct prototypes