|
|
@@ -82,23 +82,18 @@ struct mempool *mempool_create(int size, void *(* alloc) (int size), void *(* po
|
|
|
|
|
|
pool = alloc(sizeof(struct mempool));
|
|
|
|
|
|
- if (!pool) {
|
|
|
+ if (!pool)
|
|
|
/* this printk is not safe, as you know */
|
|
|
- printk("mempool_create: Out of memory\n");
|
|
|
+ panic("mempool_create: Out of memory\n");
|
|
|
|
|
|
- return NULL;
|
|
|
- }
|
|
|
|
|
|
pool->size = size;
|
|
|
|
|
|
/* we'll not free this */
|
|
|
pool->cache = pool_alloc(CACHE_SIZE);
|
|
|
|
|
|
- if (!pool->cache) {
|
|
|
- printk("mempool_create: Out of memory\n");
|
|
|
-
|
|
|
- return NULL;
|
|
|
- }
|
|
|
+ if (!pool->cache)
|
|
|
+ panic("mempool_create: Out of memory\n");
|
|
|
|
|
|
e = pool->freeptr = (struct bucket_entry *) pool->cache;
|
|
|
|
|
|
@@ -154,11 +149,8 @@ void *kmalloc(int size) {
|
|
|
if (d->size >= size)
|
|
|
break;
|
|
|
|
|
|
- if (!d->size) {
|
|
|
- printk("WARNING: kmalloc: size is too big\n");
|
|
|
-
|
|
|
- return NULL;
|
|
|
- }
|
|
|
+ if (!d->size)
|
|
|
+ panic("WARNING: kmalloc: size is too big\n");
|
|
|
|
|
|
return __mempool_alloc(d->pools);
|
|
|
}
|
|
|
@@ -173,11 +165,8 @@ int free_s(void *p, int size) {
|
|
|
if (d->size >= size && d->pools->cache == cache)
|
|
|
break;
|
|
|
|
|
|
- if (!d->size) {
|
|
|
- printk("WARNING: free_s: object is not in any mempool\n");
|
|
|
-
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ if (!d->size)
|
|
|
+ panic("WARNING: free_s: object is not in any mempool\n");
|
|
|
|
|
|
return __mempool_free(d->pools, p);
|
|
|
}
|