Dvolgyes fixes

Hi,

Please, review these fixes I made. They are basically string and memory handling related changes:
- some str*cpy change: size parameter, NUL termination, etc.
- snprintf: the size of the memory region contains the last \0, so there is no need for .... ,SIZE-1, like constants
- sometimes strncpy is just a slow implementation of memcpy
  (e.g. len=strlen(source); strncpy(target,source,len);  
   In this case strncpy will NOT copy the last \0, therefore memcpy is fine. (Or strcpy without strlen, it depends on the situation.))
 - some other small fixes.

Environment: I tested the code with tokyocabinet, using Ubuntu 12.04 (x64), gcc 4.6.3