altcp: allocate altcp_pcbs from a pool, not from heap (new option MEMP_NUM_ALTCP_PCB defaults to MEMP_NUM_TCP_PCB)

This commit is contained in:
goldsimon
2017-04-05 12:17:15 +02:00
parent 0f4ad57033
commit b34f2d5605
4 changed files with 17 additions and 4 deletions

View File

@@ -59,8 +59,7 @@ extern const struct altcp_functions altcp_tcp_functions;
struct altcp_pcb *
altcp_alloc(void)
{
/* FIXME: pool alloc */
struct altcp_pcb *ret = (struct altcp_pcb *)mem_malloc(sizeof(struct altcp_pcb));
struct altcp_pcb *ret = (struct altcp_pcb *)memp_malloc(MEMP_ALTCP_PCB);
if (ret != NULL) {
memset(ret, 0, sizeof(struct altcp_pcb));
}
@@ -70,9 +69,8 @@ altcp_alloc(void)
void
altcp_free(struct altcp_pcb *conn)
{
/* FIXME: pool alloc */
if (conn) {
mem_free(conn);
memp_free(MEMP_ALTCP_PCB, conn);
}
}

View File

@@ -57,6 +57,7 @@
#include "lwip/udp.h"
#include "lwip/tcp.h"
#include "lwip/priv/tcp_priv.h"
#include "lwip/altcp.h"
#include "lwip/ip4_frag.h"
#include "lwip/netbuf.h"
#include "lwip/api.h"