mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-23 11:44:53 +00:00
update examples
This commit is contained in:
1 parent
074ef5197b
commit
f5e2c68c8b
27 files changed
+166
-47
No files matched your search
@@ -43,7 +43,7 @@ static void set_device_id(void) {
|
||||
struct mg_str id = mg_file_read(&mg_fs_posix, "/etc/machine-id");
|
||||
if (id.buf != NULL) {
|
||||
mg_snprintf(buf, sizeof(buf), "%s", id.buf);
|
||||
free((void *) id.buf);
|
||||
mg_free((void *) id.buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -118,7 +118,7 @@ static void subscribe(struct mg_connection *c) {
|
||||
sub_opts.qos = s_qos;
|
||||
mg_mqtt_sub(c, &sub_opts);
|
||||
MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.buf));
|
||||
free(rx_topic);
|
||||
mg_free(rx_topic);
|
||||
}
|
||||
|
||||
static void rpc_config_set(struct mg_rpc_req *r) {
|
||||
@@ -169,7 +169,7 @@ static void rpc_ota_upload(struct mg_rpc_req *r) {
|
||||
} else {
|
||||
mg_rpc_ok(r, "%m", MG_ESC("ok"));
|
||||
}
|
||||
free(buf);
|
||||
mg_free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
struct mg_str topic;
|
||||
int num_topics = 0;
|
||||
while ((pos = mg_mqtt_next_sub(mm, &topic, &qos, pos)) > 0) {
|
||||
struct sub *sub = calloc(1, sizeof(*sub));
|
||||
struct sub *sub = (struct sub *)calloc(1, sizeof(*sub));
|
||||
sub->c = c;
|
||||
sub->topic = mg_strdup(topic);
|
||||
sub->qos = qos;
|
||||
@@ -128,7 +128,9 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
next = sub->next;
|
||||
if (c != sub->c) continue;
|
||||
MG_INFO(("UNSUB %p [%.*s]", c->fd, (int) sub->topic.len, sub->topic.buf));
|
||||
mg_free(sub->topic.buf);
|
||||
LIST_DELETE(struct sub, &s_subs, sub);
|
||||
free(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user