@ -235,7 +235,7 @@ static int sub__add_shared(struct mosquitto *context, const char *sub, uint8_t q
csub - > shared = shared ;
bool assigned = false ;
for ( i = 0 ; i < context - > sub _count ; i + + ) {
for ( i = 0 ; i < context - > sub s_capacity ; i + + ) {
if ( ! context - > subs [ i ] ) {
context - > subs [ i ] = csub ;
assigned = true ;
@ -243,7 +243,7 @@ static int sub__add_shared(struct mosquitto *context, const char *sub, uint8_t q
}
}
if ( assigned = = false ) {
subs = mosquitto__realloc ( context - > subs , sizeof ( struct mosquitto__client_sub * ) * ( size_t ) ( context - > sub _count + 1 ) ) ;
subs = mosquitto__realloc ( context - > subs , sizeof ( struct mosquitto__client_sub * ) * ( size_t ) ( context - > sub s_capacity + 1 ) ) ;
if ( ! subs ) {
sub__remove_shared_leaf ( subhier , shared , newleaf ) ;
mosquitto__FREE ( newleaf ) ;
@ -251,8 +251,8 @@ static int sub__add_shared(struct mosquitto *context, const char *sub, uint8_t q
return MOSQ_ERR_NOMEM ;
}
context - > subs = subs ;
context - > sub _count + + ;
context - > subs [ context - > sub _count - 1 ] = csub ;
context - > sub s_capacity + + ;
context - > subs [ context - > sub s_capacity - 1 ] = csub ;
}
# ifdef WITH_SYS_TREE
db . shared_subscription_count + + ;
@ -292,7 +292,7 @@ static int sub__add_normal(struct mosquitto *context, const char *sub, uint8_t q
csub - > shared = NULL ;
bool assigned = false ;
for ( i = 0 ; i < context - > sub _count ; i + + ) {
for ( i = 0 ; i < context - > sub s_capacity ; i + + ) {
if ( ! context - > subs [ i ] ) {
context - > subs [ i ] = csub ;
assigned = true ;
@ -300,7 +300,7 @@ static int sub__add_normal(struct mosquitto *context, const char *sub, uint8_t q
}
}
if ( assigned = = false ) {
subs = mosquitto__realloc ( context - > subs , sizeof ( struct mosquitto__client_sub * ) * ( size_t ) ( context - > sub _count + 1 ) ) ;
subs = mosquitto__realloc ( context - > subs , sizeof ( struct mosquitto__client_sub * ) * ( size_t ) ( context - > sub s_capacity + 1 ) ) ;
if ( ! subs ) {
DL_DELETE ( subhier - > subs , newleaf ) ;
mosquitto__FREE ( newleaf ) ;
@ -308,8 +308,8 @@ static int sub__add_normal(struct mosquitto *context, const char *sub, uint8_t q
return MOSQ_ERR_NOMEM ;
}
context - > subs = subs ;
context - > sub _count + + ;
context - > subs [ context - > sub _count - 1 ] = csub ;
context - > sub s_capacity + + ;
context - > subs [ context - > sub s_capacity - 1 ] = csub ;
}
# ifdef WITH_SYS_TREE
db . subscription_count + + ;
@ -379,7 +379,7 @@ static int sub__remove_normal(struct mosquitto *context, struct mosquitto__subhi
* It would be nice to be able to use the reference directly ,
* but that would involve keeping a copy of the topic string in
* each subleaf . Might be worth considering though . */
for ( i = 0 ; i < context - > sub _count ; i + + ) {
for ( i = 0 ; i < context - > sub s_capacity ; i + + ) {
if ( context - > subs [ i ] & & context - > subs [ i ] - > hier = = subhier ) {
mosquitto__FREE ( context - > subs [ i ] ) ;
break ;
@ -415,7 +415,7 @@ static int sub__remove_shared(struct mosquitto *context, struct mosquitto__subhi
* It would be nice to be able to use the reference directly ,
* but that would involve keeping a copy of the topic string in
* each subleaf . Might be worth considering though . */
for ( i = 0 ; i < context - > sub _count ; i + + ) {
for ( i = 0 ; i < context - > sub s_capacity ; i + + ) {
if ( context - > subs [ i ]
& & context - > subs [ i ] - > hier = = subhier
& & context - > subs [ i ] - > shared = = shared ) {
@ -696,7 +696,7 @@ int sub__clean_session(struct mosquitto *context)
struct mosquitto__subleaf * leaf ;
struct mosquitto__subhier * hier ;
for ( i = 0 ; i < context - > sub _count ; i + + ) {
for ( i = 0 ; i < context - > sub s_capacity ; i + + ) {
if ( context - > subs [ i ] = = NULL ) {
continue ;
}
@ -743,7 +743,7 @@ int sub__clean_session(struct mosquitto *context)
}
}
mosquitto__FREE ( context - > subs ) ;
context - > sub _count = 0 ;
context - > sub s_capacity = 0 ;
return MOSQ_ERR_SUCCESS ;
}