Multiple resource leak and NULL pointer dereferencing fixes

Fixed all memory leaks found with clang-analyser.
Fixed all NULL pointer dereferences found with clang-analyzer.

Fixed all uninitialized values used in calculations (Remaining 4 are FD_SET and FD_ZERO related, see LLVM bug 8920 for details)
Fixed all malloc sizes, now matching the appropriate type sizes. Beware: The 5 problems found in ```event.c``` are related to the ```wMessage``` being used as base type for larger structs.

Problems in ```tsmf``` channel are ignored with this patch, seperate solution for that.