[fix] Update top-level functions

that has been introduced in order to implement the mqtt layers
[fix] added missing new layer api functions
[fix] fixed cleaning of the buffers
Merge pull request #120 from xively/fix_v2

Fix HTTP+CSV
[feature] Use a dynamic buffer for xi_mqtt_layer_data_ready
Improve readability

Unimportant changes
[fix] Release memory on MQTT_SERIALISER_RC_ERROR
[fix] Do not release buffer memory on EAGAIN
[fix] memory leak when the layer is disconnected

This situation may happen whenever the client is disconnected while sending a message
[fix] Release memory on err_handling.

We also need to declare both pointers before allocating any of them, just in case we run out of memory while allocating the first and try to use the second one in the subroutine.