Annotation of mqtt/src/recv.c, revision 1.1.2.1
1.1.2.1 ! misho 1: #include "global.h"
! 2:
! 3:
! 4: /* ------------------------------------------------------------------- */
! 5:
! 6: /*
! 7: * mqttInitCallbacks() Init callback array for dispatcher
! 8: *
! 9: * return: NULL error or !=NULL allocated callback array, after use free with mqttFiniCallbacks()
! 10: */
! 11: mqtt_cb_t *
! 12: mqttInitCallbacks(void)
! 13: {
! 14: mqtt_cb_t *cb = NULL;
! 15:
! 16: cb = malloc((MQTT_TYPE_MAX + 1) * sizeof(mqtt_cb_t));
! 17: if (!cb) {
! 18: LOGERR;
! 19: return NULL;
! 20: } else
! 21: memset(cb, 0, (MQTT_TYPE_MAX + 1) * sizeof(mqtt_cb_t));
! 22:
! 23: return cb;
! 24: }
! 25:
! 26: /*
! 27: * mqttFiniCallbacks() Free callback array
! 28: *
! 29: * @cb = Callback array
! 30: * return: none
! 31: */
! 32: void
! 33: mqttFiniCallbacks(mqtt_cb_t ** __restrict cb)
! 34: {
! 35: if (!cb)
! 36: return;
! 37:
! 38: if ((*cb)[MQTT_TYPE_MAX])
! 39: (*cb)[MQTT_TYPE_MAX](*cb);
! 40:
! 41: free(*cb);
! 42: *cb = NULL;
! 43: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>