diff options
Diffstat (limited to 'libports')
-rw-r--r-- | libports/create-bucket.c | 27 | ||||
-rw-r--r-- | libports/create-class.c | 11 |
2 files changed, 30 insertions, 8 deletions
diff --git a/libports/create-bucket.c b/libports/create-bucket.c index d523b788..9e25ab60 100644 --- a/libports/create-bucket.c +++ b/libports/create-bucket.c @@ -1,5 +1,5 @@ /* Create a port bucket - Copyright (C) 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 2001 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -19,7 +19,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ports.h" -#include <assert.h> +#include <errno.h> +#include <stdlib.h> #include <hurd/ihash.h> #include <cthreads.h> @@ -30,14 +31,30 @@ ports_create_bucket () error_t err; ret = malloc (sizeof (struct port_bucket)); - assert (ret); + if (! ret) + { + errno = ENOMEM; + return NULL; + } err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_PORT_SET, &ret->portset); - assert_perror (err); + if (err) + { + errno = err; + free (ret); + return NULL; + } err = ihash_create (&ret->htable); - assert_perror (err); + if (err) + { + errno = err; + mach_port_mod_refs (mach_task_self (), ret->portset, + MACH_PORT_RIGHT_PORT_SET, -1); + free (ret); + return NULL; + } ret->rpcs = ret->flags = ret->count = 0; diff --git a/libports/create-class.c b/libports/create-class.c index 7db99ca1..12c8add9 100644 --- a/libports/create-class.c +++ b/libports/create-class.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995,2001 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -20,7 +20,7 @@ #include "ports.h" #include <stdlib.h> -#include <assert.h> +#include <errno.h> struct port_class * ports_create_class (void (*clean_routine)(void *), @@ -29,7 +29,12 @@ ports_create_class (void (*clean_routine)(void *), struct port_class *cl; cl = malloc (sizeof (struct port_class)); - assert (cl); + if (! cl) + { + errno = ENOMEM; + return NULL; + } + cl->clean_routine = clean_routine; cl->dropweak_routine = dropweak_routine; cl->flags = 0; |