diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-09-10 23:04:27 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-09-10 23:04:27 +0000 |
commit | bad8adf0aa67301e3b78675a20687f21119ff9cd (patch) | |
tree | 1e48672e329fe0491dd39ea6860771a7b4a13cb1 /lib | |
parent | 87d628039c21fa36723e62b3e2ff7b7bf033c7d8 (diff) |
Use realloc() instead of malloc().
From: Alexander dot Farber at gmail dot com
ok deraadt@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/rpc/svc_run.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c index 56a7b0d5af7..40afd62a810 100644 --- a/lib/libc/rpc/svc_run.c +++ b/lib/libc/rpc/svc_run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svc_run.c,v 1.16 2005/08/08 08:05:35 espie Exp $ */ +/* $OpenBSD: svc_run.c,v 1.17 2005/09/10 23:04:26 brad Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -42,17 +42,18 @@ void svc_run(void) { - struct pollfd *pfd = NULL; + struct pollfd *pfd = NULL, *newp; int nready, saved_max_pollfd = 0; for (;;) { if (svc_max_pollfd > saved_max_pollfd) { - free(pfd); - pfd = malloc(sizeof(*pfd) * svc_max_pollfd); - if (pfd == NULL) { + newp = realloc(pfd, sizeof(*pfd) * svc_max_pollfd); + if (newp == NULL) { + free(pfd); perror("svc_run"); /* XXX */ return; /* XXX */ } + pfd = newp; saved_max_pollfd = svc_max_pollfd; } memcpy(pfd, svc_pollfd, sizeof(*pfd) * svc_max_pollfd); |