8000 Heap optimization (#471) · c0zm0z/arduino-esp32@cfde557 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cfde557

Browse files
copercinime-no-dev
authored andcommitted
Heap optimization (espressif#471)
* Remove duplicated include * Clear certificates just after handshake It can save up to 7k of heap
1 parent 8709336 commit cfde557

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

libraries/WiFiClientSecure/src/ssl_client.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "Arduino.h"
1010
#include <esp32-hal-log.h>
11-
#include <lwip/sockets.h>
1211
#include <lwip/err.h>
1312
#include <lwip/sockets.h>
1413
#include <lwip/sys.h>
@@ -181,6 +180,18 @@ int start_ssl_client(sslclient_context *ssl_client, uint32_t ipAddress, uint32_t
181180
} else {
182181
log_i("Certificate verified.");
183182
}
183+
184+
if (rootCABuff != NULL) {
185+
mbedtls_x509_crt_free(&ssl_client->ca_cert);
186+
}
187+
188+
if (cli_cert != NULL) {
189+
mbedtls_x509_crt_free(&ssl_client->client_cert);
190+
}
191+
192+
if (cli_key != NULL) {
193+
mbedtls_pk_free(&ssl_client->client_key);
194+
}
184195

185196
log_i("Free heap after TLS %u", xPortGetFreeHeapSize());
186197

@@ -201,18 +212,6 @@ void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, cons
201212
mbedtls_ssl_config_free(&ssl_client->ssl_conf);
202213
mbedtls_ctr_drbg_free(&ssl_client->drbg_ctx);
203214
mbedtls_entropy_free(&ssl_client->entropy_ctx);
204-
205-
if (rootCABuff != NULL) {
206-
mbedtls_x509_crt_free(&ssl_client->ca_cert);
207-
}
208-
209-
if (cli_cert != NULL) {
210-
mbedtls_x509_crt_free(&ssl_client->client_cert);
211-
}
212-
213-
if (cli_key != NULL) {
214-
mbedtls_pk_free(&ssl_client->client_key);
215-
}
216215
}
217216

218217

0 commit comments

Comments
 (0)
0