forked from wolfSSL/wolfssl
Merge pull request #771 from JacobBarthelmeh/master
account for static memory IO_POOL free when general memory was used
This commit is contained in:
@@ -539,7 +539,9 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* case of using fixed IO buffers */
|
/* case of using fixed IO buffers */
|
||||||
if (mem->flag & WOLFMEM_IO_POOL_FIXED) {
|
if (mem->flag & WOLFMEM_IO_POOL_FIXED &&
|
||||||
|
(type == DYNAMIC_TYPE_OUT_BUFFER ||
|
||||||
|
type == DYNAMIC_TYPE_IN_BUFFER)) {
|
||||||
if (type == DYNAMIC_TYPE_OUT_BUFFER) {
|
if (type == DYNAMIC_TYPE_OUT_BUFFER) {
|
||||||
pt = hint->outBuf;
|
pt = hint->outBuf;
|
||||||
}
|
}
|
||||||
@@ -547,9 +549,9 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
|||||||
pt = hint->inBuf;
|
pt = hint->inBuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
/* check if using IO pool flag */
|
/* check if using IO pool flag */
|
||||||
if (mem->flag & WOLFMEM_IO_POOL && pt == NULL &&
|
if (mem->flag & WOLFMEM_IO_POOL &&
|
||||||
(type == DYNAMIC_TYPE_OUT_BUFFER ||
|
(type == DYNAMIC_TYPE_OUT_BUFFER ||
|
||||||
type == DYNAMIC_TYPE_IN_BUFFER)) {
|
type == DYNAMIC_TYPE_IN_BUFFER)) {
|
||||||
if (mem->io != NULL) {
|
if (mem->io != NULL) {
|
||||||
@@ -570,6 +572,7 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pt != NULL) {
|
if (pt != NULL) {
|
||||||
mem->inUse += pt->sz;
|
mem->inUse += pt->sz;
|
||||||
@@ -672,7 +675,7 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
|
|||||||
/* fixed IO pools are free'd at the end of SSL lifetime
|
/* fixed IO pools are free'd at the end of SSL lifetime
|
||||||
using FreeFixedIO(WOLFSSL_HEAP* heap, wc_Memory** io) */
|
using FreeFixedIO(WOLFSSL_HEAP* heap, wc_Memory** io) */
|
||||||
}
|
}
|
||||||
else if (mem->flag & WOLFMEM_IO_POOL &&
|
else if (mem->flag & WOLFMEM_IO_POOL && pt->sz == WOLFMEM_IO_SZ &&
|
||||||
(type == DYNAMIC_TYPE_OUT_BUFFER ||
|
(type == DYNAMIC_TYPE_OUT_BUFFER ||
|
||||||
type == DYNAMIC_TYPE_IN_BUFFER)) {
|
type == DYNAMIC_TYPE_IN_BUFFER)) {
|
||||||
pt->next = mem->io;
|
pt->next = mem->io;
|
||||||
|
Reference in New Issue
Block a user