diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-11-21 14:46:55 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-11-21 15:32:28 +0400 |
commit | 3a494648526be4eb96cba739a816a60e933ffd14 (patch) | |
tree | 878b7e916c072d6844bb02f5125102434453cb18 /src/tcp_subr.c | |
parent | 61f54d2e4a7ae77065ac2249659c2f1a9a0a2cf5 (diff) | |
download | slirp-3a494648526be4eb96cba739a816a60e933ffd14.zip slirp-3a494648526be4eb96cba739a816a60e933ffd14.tar.gz slirp-3a494648526be4eb96cba739a816a60e933ffd14.tar.bz2 |
Replace remaining malloc/free user with glib
glib mem functions are already used in various places. Let's not mix
the two, and instead abort on OOM conditions.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'src/tcp_subr.c')
-rw-r--r-- | src/tcp_subr.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/tcp_subr.c b/src/tcp_subr.c index 2e32cb6..e54f8fa 100644 --- a/src/tcp_subr.c +++ b/src/tcp_subr.c @@ -255,11 +255,7 @@ struct tcpcb *tcp_newtcpcb(struct socket *so) { register struct tcpcb *tp; - tp = (struct tcpcb *)malloc(sizeof(*tp)); - if (tp == NULL) - return ((struct tcpcb *)0); - - memset((char *)tp, 0, sizeof(struct tcpcb)); + tp = g_new0(struct tcpcb, 1); tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp; /* * 40: length of IPv4 header (20) + TCP header (20) @@ -336,7 +332,7 @@ struct tcpcb *tcp_close(struct tcpcb *tp) remque(tcpiphdr2qlink(tcpiphdr_prev(t))); m_free(m); } - free(tp); + g_free(tp); so->so_tcpcb = NULL; /* clobber input socket cache if we're closing the cached connection */ if (so == slirp->tcp_last_so) |