unreferenced macro removed
extra semicolons removed
extra semicolons removed; int replaced with size_t where possible
defines moved out of the function body
missing 'extern' added