From 3d38af5174d388e9d5f13522ace5ab1b4ac10076 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Tue, 26 Apr 2016 21:33:02 +0200 Subject: [PATCH] Work on bug #47512: MPU_COMPATIBLE may fail on empty pool (not finished!) --- src/api/api_lib.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 3f46d623..3a87c297 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -55,11 +55,12 @@ #include -#define API_MSG_VAR_REF(name) API_VAR_REF(name) -#define API_MSG_VAR_DECLARE(name) API_VAR_DECLARE(struct api_msg, name) -#define API_MSG_VAR_ALLOC(name) API_VAR_ALLOC(struct api_msg, MEMP_API_MSG, name, ERR_MEM) -#define API_MSG_VAR_ALLOC_DONTFAIL(name) API_VAR_ALLOC_DONTFAIL(struct api_msg, MEMP_API_MSG, name) -#define API_MSG_VAR_FREE(name) API_VAR_FREE(MEMP_API_MSG, name) +#define API_MSG_VAR_REF(name) API_VAR_REF(name) +#define API_MSG_VAR_DECLARE(name) API_VAR_DECLARE(struct api_msg, name) +#define API_MSG_VAR_ALLOC(name) API_VAR_ALLOC(struct api_msg, MEMP_API_MSG, name, ERR_MEM) +#define API_MSG_VAR_ALLOC_RETURN_NULL(name) API_VAR_ALLOC(struct api_msg, MEMP_API_MSG, name, NULL) +#define API_MSG_VAR_ALLOC_DONTFAIL(name) API_VAR_ALLOC_DONTFAIL(struct api_msg, MEMP_API_MSG, name) +#define API_MSG_VAR_FREE(name) API_VAR_FREE(MEMP_API_MSG, name) static err_t netconn_close_shutdown(struct netconn *conn, u8_t how); @@ -105,15 +106,15 @@ netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_cal { struct netconn *conn; API_MSG_VAR_DECLARE(msg); + API_MSG_VAR_ALLOC_RETURN_NULL(msg); conn = netconn_alloc(t, callback); if (conn != NULL) { err_t err; - API_MSG_VAR_ALLOC_DONTFAIL(msg); + API_MSG_VAR_REF(msg).msg.n.proto = proto; API_MSG_VAR_REF(msg).conn = conn; err = netconn_apimsg(lwip_netconn_do_newconn, &API_MSG_VAR_REF(msg)); - API_MSG_VAR_FREE(msg); if (err != ERR_OK) { LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL); LWIP_ASSERT("conn has no recvmbox", sys_mbox_valid(&conn->recvmbox)); @@ -126,9 +127,11 @@ netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_cal #endif /* !LWIP_NETCONN_SEM_PER_THREAD */ sys_mbox_free(&conn->recvmbox); memp_free(MEMP_NETCONN, conn); + API_MSG_VAR_FREE(msg); return NULL; } } + API_MSG_VAR_FREE(msg); return conn; }