Replaced int with size_t where suitable
res was being used without being initialised
Removed a bunch of unreferenced vars/labels
Fixes a potential crash if no params are passed
Fixes crash - arguments were in the wrong order
Removed futile attempt to handle a failed malloc - just exit instead
Fixed potential null dereference - seems the function was never used in a way that would cause it but the intention to be able to pass null for msg seems clear
Removed pointless attempt to handle failed malloc and fixed a memory leak
Removed pointless null check on 'chan' - the new operator will throw an exception if it fails.
Fixed a potential null pointer dereference.
Fixed memory leak
Fixed memory leak.
Removed pointless attempt to recover after a failed malloc.
Fixed memory leak.
Fixed memory leak.
Fixed potential null pointer dereference.
Fixed memory corruption - wrong memcpy source argument
Fixed potential infinite loop caused by failed allocation. Better to just exit.
Merge pull request #1 from Chaosvex/fixes

Minor fixes