mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-18 19:31:02 +00:00
mg_rpc_free -> mg_rpc_del
This commit is contained in:
1 parent
43d53b0616
commit
f02f88f336
5 files changed
+23
-15
No files matched your search
+10
-6
@@ -3573,12 +3573,16 @@ void mg_rpc_add(void **head, struct mg_str method,
|
|||||||
rpc->next = (struct mg_rpc *) *head, *head = rpc;
|
rpc->next = (struct mg_rpc *) *head, *head = rpc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_rpc_free(void **head) {
|
void mg_rpc_del(void **head, void (*fn)(struct mg_rpc_req *)) {
|
||||||
while (head != NULL && *head != NULL) {
|
struct mg_rpc *r, **h = (struct mg_rpc **) head;
|
||||||
struct mg_rpc *rpc = *(struct mg_rpc **) head;
|
while ((r = *h) != NULL) {
|
||||||
*head = rpc->next;
|
if (r->fn == fn || fn == NULL) {
|
||||||
free((void *) rpc->method.ptr);
|
*h = r->next;
|
||||||
free(rpc);
|
free((void *) r->method.ptr);
|
||||||
|
free(r);
|
||||||
|
} else {
|
||||||
|
h = &(*h)->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1374,7 +1374,7 @@ struct mg_rpc_req {
|
|||||||
|
|
||||||
void mg_rpc_add(void **head, struct mg_str method_pattern,
|
void mg_rpc_add(void **head, struct mg_str method_pattern,
|
||||||
void (*handler)(struct mg_rpc_req *), void *handler_data);
|
void (*handler)(struct mg_rpc_req *), void *handler_data);
|
||||||
void mg_rpc_free(void **head);
|
void mg_rpc_del(void **head, void (*handler)(struct mg_rpc_req *));
|
||||||
void mg_rpc_process(struct mg_rpc_req *);
|
void mg_rpc_process(struct mg_rpc_req *);
|
||||||
|
|
||||||
// Helper functions to print result or error frame
|
// Helper functions to print result or error frame
|
||||||
|
|||||||
@@ -14,12 +14,16 @@ void mg_rpc_add(void **head, struct mg_str method,
|
|||||||
rpc->next = (struct mg_rpc *) *head, *head = rpc;
|
rpc->next = (struct mg_rpc *) *head, *head = rpc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_rpc_free(void **head) {
|
void mg_rpc_del(void **head, void (*fn)(struct mg_rpc_req *)) {
|
||||||
while (head != NULL && *head != NULL) {
|
struct mg_rpc *r, **h = (struct mg_rpc **) head;
|
||||||
struct mg_rpc *rpc = *(struct mg_rpc **) head;
|
while ((r = *h) != NULL) {
|
||||||
*head = rpc->next;
|
if (r->fn == fn || fn == NULL) {
|
||||||
free((void *) rpc->method.ptr);
|
*h = r->next;
|
||||||
free(rpc);
|
free((void *) r->method.ptr);
|
||||||
|
free(r);
|
||||||
|
} else {
|
||||||
|
h = &(*h)->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ struct mg_rpc_req {
|
|||||||
|
|
||||||
void mg_rpc_add(void **head, struct mg_str method_pattern,
|
void mg_rpc_add(void **head, struct mg_str method_pattern,
|
||||||
void (*handler)(struct mg_rpc_req *), void *handler_data);
|
void (*handler)(struct mg_rpc_req *), void *handler_data);
|
||||||
void mg_rpc_free(void **head);
|
void mg_rpc_del(void **head, void (*handler)(struct mg_rpc_req *));
|
||||||
void mg_rpc_process(struct mg_rpc_req *);
|
void mg_rpc_process(struct mg_rpc_req *);
|
||||||
|
|
||||||
// Helper functions to print result or error frame
|
// Helper functions to print result or error frame
|
||||||
|
|||||||
+1
-1
@@ -2476,7 +2476,7 @@ static void test_rpc(void) {
|
|||||||
free(s), s = NULL;
|
free(s), s = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mg_rpc_free(&head);
|
mg_rpc_del(&head, NULL);
|
||||||
ASSERT(head == NULL);
|
ASSERT(head == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user