Fixed some typos, minor cleanup.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10659 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-01-10 18:30:37 +00:00
parent 30ec9a55ef
commit d1f630f624
+29 -21
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002-04, Thomas Kurschel. All rights reserved. * Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
/* /*
@@ -12,7 +12,7 @@
IDs are freed. They have a ref_count which is increased IDs are freed. They have a ref_count which is increased
whenever someone messes with the generator. whenever someone messes with the generator.
Whenever a generator is search for, generator_lock is hold. Whenever a generator is searched for, generator_lock is held.
To find out which ID are allocated, a bitmap is used that To find out which ID are allocated, a bitmap is used that
contain up to GENERATOR_MAX_ID bits. This is a hard limit, contain up to GENERATOR_MAX_ID bits. This is a hard limit,
@@ -44,8 +44,9 @@ struct list sGenerators;
static benaphore sGeneratorLock; static benaphore sGeneratorLock;
// create new generator /** Create new generator
// sGeneratorLock must be hold * sGeneratorLock must be held
*/
static id_generator * static id_generator *
create_generator(const char *name) create_generator(const char *name)
@@ -69,12 +70,11 @@ create_generator(const char *name)
generator->ref_count = 1; generator->ref_count = 1;
list_add_link_to_head(&sGenerators, generator); list_add_link_to_head(&sGenerators, generator);
// ADD_DL_LIST_HEAD( generator, generator_list, );
return generator; return generator;
} }
// allocate id /** allocate id */
static int32 static int32
create_id_internal(id_generator *generator) create_id_internal(id_generator *generator)
@@ -105,8 +105,9 @@ create_id_internal(id_generator *generator)
} }
// find generator by name /** Find generator by name
// sGeneratorLock must be hold * sGeneratorLock must be held
*/
static id_generator * static id_generator *
find_generator(const char *name) find_generator(const char *name)
@@ -127,7 +128,7 @@ find_generator(const char *name)
} }
// decrease ref_count, deleting generator if not used anymore /** Decrease ref_count, deleting generator if not used anymore */
static void static void
release_generator(id_generator *generator) release_generator(id_generator *generator)
@@ -142,7 +143,6 @@ release_generator(id_generator *generator)
TRACE(("Destroy %s\n", generator->name)); TRACE(("Destroy %s\n", generator->name));
// no IDs is allocated - destroy generator // no IDs is allocated - destroy generator
list_remove_link(generator); list_remove_link(generator);
//REMOVE_DL_LIST( generator, generator_list, );
free(generator->name); free(generator->name);
free(generator); free(generator);
} }
@@ -152,7 +152,23 @@ release_generator(id_generator *generator)
} }
// public: create automatic ID // #pragma mark -
// Private kernel API
status_t
id_generator_init(void)
{
list_init(&sGenerators);
return benaphore_init(&sGeneratorLock, "id generator");
}
// #pragma mark -
// Public API
/** Create automatic ID */
int32 int32
pnp_create_id(const char *name) pnp_create_id(const char *name)
@@ -182,7 +198,7 @@ pnp_create_id(const char *name)
} }
// public: free automatically generated ID /** Free automatically generated ID */
status_t status_t
pnp_free_id(const char *name, uint32 id) pnp_free_id(const char *name, uint32 id)
@@ -222,11 +238,3 @@ pnp_free_id(const char *name, uint32 id)
return B_OK; return B_OK;
} }
status_t
id_generator_init(void)
{
list_init(&sGenerators);
return benaphore_init(&sGeneratorLock, "id generator");
}