Skip to content

Commit 207d729

Browse files
committed
esp32/modsocket: Use m_new_obj_with_finaliser instead of calloc.
1 parent 864d527 commit 207d729

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

esp32/modsocket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ STATIC mp_obj_t socket_accept(const mp_obj_t arg0) {
119119
socket_obj_t *self = MP_OBJ_TO_PTR(arg0);
120120
int x = lwip_accept(self->fd, NULL, NULL);
121121
if (x >= 0) {
122-
socket_obj_t *sock = (socket_obj_t *)calloc(1, sizeof(socket_obj_t));
122+
socket_obj_t *sock = m_new_obj_with_finaliser(socket_obj_t);
123123
sock->base.type = self->base.type;
124124
sock->fd = x;
125125
return MP_OBJ_FROM_PTR(sock);
@@ -315,7 +315,7 @@ STATIC const mp_obj_type_t socket_type = {
315315

316316
STATIC mp_obj_t get_socket(mp_uint_t n_args, const mp_obj_t *args) {
317317
// XXX TODO support for UDP and RAW.
318-
socket_obj_t *sock = (socket_obj_t *)calloc(1, sizeof(socket_obj_t));
318+
socket_obj_t *sock = m_new_obj_with_finaliser(socket_obj_t);
319319
sock->base.type = &socket_type;
320320
sock->domain = AF_INET;
321321
sock->type = SOCK_STREAM;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy