last cleanup of pool code before rewriting it

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2106 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2002-11-28 15:05:58 +00:00
parent 9c2992c73b
commit 428f0ce25c
3 changed files with 7 additions and 15 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
/* pools.h
/* pools.h
* simple fixed size block allocator
*/
@@ -47,7 +47,7 @@ struct pool_ctl {
};
int32 pool_init(pool_ctl **p, size_t sz);
char *pool_get(pool_ctl *p);
void *pool_get(pool_ctl *p);
void pool_put(pool_ctl *p, void *ptr);
void pool_destroy(pool_ctl *p);
void pool_debug(struct pool_ctl *p, char *name);
+2 -2
View File
@@ -338,7 +338,7 @@ find_entry(new_hash_table *nh, const void *key, ssize_t klen, const void *val)
hash = hash * 33 + *p;
for (hep = &nh->array[hash & nh->max], he = *hep; he; hep = &he->next, he = *hep) {
dprintf("khash, find_entry looking at hep %p, he %p\n", hep, he);
// dprintf("khash, find_entry looking at hep %p, he %p\n", hep, he);
if (he->hash == hash && he->klen == klen
&& memcmp(he->key, key, klen) == 0) {
break;
@@ -368,7 +368,7 @@ hash_get(new_hash_table *nh, const void *key, ssize_t klen)
hash_entry *hep;
hepp = find_entry(nh, key, klen, NULL);
dprintf("khash, find_entry returned %p\n", hepp);
// dprintf("khash, find_entry returned %p\n", hepp);
if (hepp == NULL)
return NULL;
+3 -11
View File
@@ -15,7 +15,6 @@
#include <debug.h>
#include <pools.h>
static sem_id init_sem = -1;
#define POOL_ALLOC_SZ 4 * 1024
#define ROUND_TO_PAGE_SIZE(x) (((x) + (POOL_ALLOC_SZ) - 1) & ~((POOL_ALLOC_SZ) - 1))
@@ -76,7 +75,7 @@ static struct pool_mem *get_mem_block(struct pool_ctl *pool)
memset(block, 0, sizeof(*block));
block->aid = vm_create_anonymous_region(vm_get_kernel_aspace_id(),
"net_stack_pools_block",
"some pool block",
(void**)&block->base_addr,
REGION_ADDR_ANY_ADDRESS, pool->block_size,
REGION_WIRING_WIRED_CONTIG,
@@ -129,15 +128,10 @@ int32 pool_init(struct pool_ctl **_newPool, size_t size)
/* if the init failes, the new pool will be set to NULL */
*_newPool = NULL;
if (init_sem == -1)
create_sem(1, "pool_init_sem");
/* minimum block size is sizeof the free_blk structure */
if (size < sizeof(struct free_blk))
return EINVAL;
size = sizeof(struct free_blk);
// acquire_sem_etc(init_sem, 1, B_CAN_INTERRUPT, 0);
pool = (struct pool_ctl *)malloc(sizeof(struct pool_ctl));
if (pool == NULL)
return ENOMEM;
@@ -177,13 +171,11 @@ int32 pool_init(struct pool_ctl **_newPool, size_t size)
}
*_newPool = pool;
// release_sem_etc(init_sem, 1, B_CAN_INTERRUPT);
return 0;
}
char *pool_get(struct pool_ctl *p)
void *pool_get(struct pool_ctl *p)
{
/* ok, so now we look for a suitable block... */
struct pool_mem *mp = p->list;