diff options
Diffstat (limited to 'libports/create-bucket.c')
-rw-r--r-- | libports/create-bucket.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/libports/create-bucket.c b/libports/create-bucket.c index 1c3346e4..6be4bcad 100644 --- a/libports/create-bucket.c +++ b/libports/create-bucket.c @@ -1,5 +1,5 @@ /* Create a port bucket - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 2001, 2003 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -19,7 +19,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ports.h" -#include <assert.h> +#include <stddef.h> +#include <errno.h> +#include <stdlib.h> #include <hurd/ihash.h> #include <cthreads.h> @@ -30,18 +32,28 @@ 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); - err = ihash_create (&ret->htable); - assert_perror (err); + if (err) + { + errno = err; + free (ret); + return NULL; + } + + hurd_ihash_init (&ret->htable, offsetof (struct port_info, hentry)); + ret->rpcs = ret->flags = ret->count = 0; mutex_lock (&_ports_lock); ret->next = _ports_all_buckets; _ports_all_buckets = ret; mutex_unlock (&_ports_lock); + return ret; } - - |