rizsotto/Bear — pull request #34 by mlq (2013-07-10 23:00:13+00:00)
Title: Correct usage of malloc and realloc

Those three patches bear the following:

* Reset released string parameter correctly
The statement that sets in to 0 has no effect, therefore it has to be dereferenced first.

* Do not cast the return value of malloc/realloc
Since that a void pointer in C can be assigned to any pointer without an explicit cast the casting is
unnecessary. In addition it makes the code more readible.

* Free allocated memory upon realloc failure
If realloc fails it does not release the already allocated memory, therefore we have to store the return
value of realloc in a temporary variable to check if it had failed or not. If it did, we can safely free the already
allocated memory, otherwise we set the pointer to the new one.