]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/respool.c
Trans: Document which modules have to be resourcified
[libucw.git] / ucw / respool.c
index a4978fdf51ad030ff323cd00aa2b3336acd9d951..64f9a2fc643f14abcbf7d85edbabdb8643aba8a2 100644 (file)
@@ -99,8 +99,7 @@ struct resource *
 res_alloc(const struct res_class *rc)
 {
   struct respool *rp = rp_current();
 res_alloc(const struct res_class *rc)
 {
   struct respool *rp = rp_current();
-  if (!rp)
-    return NULL;
+  ASSERT(rp);
 
   uns size = (rc->res_size ? : sizeof(struct resource));
   struct resource *r = (rp->mpool ? mp_alloc_fast(rp->mpool, size) : xmalloc(size));
 
   uns size = (rc->res_size ? : sizeof(struct resource));
   struct resource *r = (rp->mpool ? mp_alloc_fast(rp->mpool, size) : xmalloc(size));
@@ -121,6 +120,8 @@ res_drop(struct resource *r)
 void
 res_detach(struct resource *r)
 {
 void
 res_detach(struct resource *r)
 {
+  if (!r)
+    return;
   if (r->rclass->detach)
     r->rclass->detach(r);
   res_drop(r);
   if (r->rclass->detach)
     r->rclass->detach(r);
   res_drop(r);
@@ -129,6 +130,8 @@ res_detach(struct resource *r)
 void
 res_free(struct resource *r)
 {
 void
 res_free(struct resource *r)
 {
+  if (!r)
+    return;
   if (r->rclass->free)
     r->rclass->free(r);
   res_drop(r);
   if (r->rclass->free)
     r->rclass->free(r);
   res_drop(r);