diff options
author | Roland McGrath <roland@gnu.org> | 2001-03-31 23:06:50 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-03-31 23:06:50 +0000 |
commit | 8a97bddd0358698b14cd99a9fe465b6d8f79c48c (patch) | |
tree | 5998d77370c7bba91ff7f8d73cdf72d64df92faf /libports/create-bucket.c | |
parent | 401faf3bb898ddb4f7c025a4f9a78386cc381e0b (diff) |
2001-03-29 Neal H Walfield <neal@cs.uml.edu>
* create-bucket.c (ports_create_bucket): Include errno.h
and stdlib.h. Do not include assert.h. Turn assertions
into errors that set errno and return NULL.
* create-class.c (ports_create_class): Likewise.
Diffstat (limited to 'libports/create-bucket.c')
-rw-r--r-- | libports/create-bucket.c | 27 |
1 files changed, 22 insertions, 5 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; |