Diff for /libaitmqtt/src/aitmqtt.c between versions 1.3 and 1.3.4.1

version 1.3, 2013/05/30 09:18:33 version 1.3.4.1, 2022/09/13 20:12:15
Line 133  mqtt_msgFree(mqtt_msg_t ** __restrict msg, int all) Line 133  mqtt_msgFree(mqtt_msg_t ** __restrict msg, int all)
  * return: NULL error or Message, after use must call mqtt_msgFree() with all!=0   * return: NULL error or Message, after use must call mqtt_msgFree() with all!=0
  */   */
 mqtt_msg_t *  mqtt_msg_t *
mqtt_msgAlloc(u_short len)mqtt_msgAlloc(u_int len)
 {  {
         mqtt_msg_t *m = NULL;          mqtt_msg_t *m = NULL;
   
Line 166  mqtt_msgAlloc(u_short len) Line 166  mqtt_msgAlloc(u_short len)
  * return: -1 error or >-1 old buffer length   * return: -1 error or >-1 old buffer length
  */   */
 int  int
mqtt_msgRealloc(mqtt_msg_t * __restrict msg, u_short len)mqtt_msgRealloc(mqtt_msg_t * __restrict msg, u_int len)
 {  {
         void *p = NULL;          void *p = NULL;
         int ret = 0;          int ret = 0;
Line 234  mqtt_encodeLen(u_int num) Line 234  mqtt_encodeLen(u_int num)
         register u_int dig, i;          register u_int dig, i;
         u_int ret = 0;          u_int ret = 0;
   
        if (num > 268435455)        if (num > MQTT_DATA_MAX)
                 return (u_int) -1;                  return (u_int) -1;
   
         for (i = 0; i < sizeof ret && num > 0; i++) {          for (i = 0; i < sizeof ret && num > 0; i++) {
Line 276  mqtt_decodeLen(void * __restrict len, int * __restrict Line 276  mqtt_decodeLen(void * __restrict len, int * __restrict
   
         if (n)          if (n)
                 *n = (char) (i & 0x7f) + 1;                  *n = (char) (i & 0x7f) + 1;
   
         return ret;          return ret;
 }  }
   
Line 325  mqtt_pktLen(struct mqtthdr * __restrict hdr) Line 326  mqtt_pktLen(struct mqtthdr * __restrict hdr)
  * mqtt_str2subs Create MQTT subscribe variable from string(s)   * mqtt_str2subs Create MQTT subscribe variable from string(s)
  *   *
  * @csStr = null terminated string array   * @csStr = null terminated string array
 * @strnum = copy at most number of strings elements * @strnum = copy at most number of strings elements, ==0 till NULL element
  * @qoses = QoS elements applied to subscribe variable,    * @qoses = QoS elements applied to subscribe variable, 
  *              count of elements must be equal with csStr elements   *              count of elements must be equal with csStr elements
  * return: NULL error or != subscribe variables array, must be free after use with mqtt_freeSub()   * return: NULL error or != subscribe variables array, must be free after use with mqtt_freeSub()
  */   */
 mqtt_subscr_t *  mqtt_subscr_t *
mqtt_str2subs(const char **csStr, u_short strnum, u_char *qoses)mqtt_strs2subs(const char **csStr, u_short strnum, u_char *qoses)
 {  {
         mqtt_subscr_t *v;          mqtt_subscr_t *v;
         register int i, items;          register int i, items;
Line 421  mqtt_subAlloc(u_short num) Line 422  mqtt_subAlloc(u_short num)
 mqtt_subscr_t *  mqtt_subscr_t *
 mqtt_subRealloc(mqtt_subscr_t ** __restrict subs, u_short num)  mqtt_subRealloc(mqtt_subscr_t ** __restrict subs, u_short num)
 {  {
        mqtt_subscr_t *s = NULL;        mqtt_subscr_t **ss, *s = NULL;
         register int i;
   
         if (!subs)          if (!subs)
                 return NULL;                  return NULL;
   
           for (i = 0, ss = subs; *ss; i++, ss++);
           if (i < num)
                   return NULL;
           if (i == num)
                   return *subs;
   
         s = realloc(*subs, (num + 1) * sizeof(mqtt_subscr_t));          s = realloc(*subs, (num + 1) * sizeof(mqtt_subscr_t));
         if (!s) {          if (!s) {
                 LOGERR;                  LOGERR;
Line 464  mqtt_subCopy(mqtt_subscr_t * __restrict dst, mqtt_subs Line 472  mqtt_subCopy(mqtt_subscr_t * __restrict dst, mqtt_subs
                                         dst->sub_topic.msg_len);                                          dst->sub_topic.msg_len);
                 }                  }
         } else {          } else {
                 /*  
                 if (dst->sub_topic.msg_base)  
                         free(dst->sub_topic.msg_base);  
                         */  
                 dst->sub_topic.msg_base = NULL;                  dst->sub_topic.msg_base = NULL;
                 dst->sub_topic.msg_len = 0;                  dst->sub_topic.msg_len = 0;
         }          }
   
         if (src->sub_value.msg_base) {          if (src->sub_value.msg_base) {
                 dst->sub_value.msg_base = malloc(src->sub_value.msg_len + 1);                  dst->sub_value.msg_base = malloc(src->sub_value.msg_len + 1);
                 if (!dst->sub_value.msg_base) {                  if (!dst->sub_value.msg_base) {
Line 486  mqtt_subCopy(mqtt_subscr_t * __restrict dst, mqtt_subs Line 491  mqtt_subCopy(mqtt_subscr_t * __restrict dst, mqtt_subs
                                         dst->sub_value.msg_len);                                          dst->sub_value.msg_len);
                 }                  }
         } else {          } else {
                 /*  
                 if (dst->sub_value.msg_base)  
                         free(dst->sub_value.msg_base);  
                         */  
                 dst->sub_value.msg_base = NULL;                  dst->sub_value.msg_base = NULL;
                 dst->sub_value.msg_len = 0;                  dst->sub_value.msg_len = 0;
         }          }

Removed from v.1.3  
changed lines
  Added in v.1.3.4.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>