xvalloc is the wrapper function of valloc in lib/util.
We should use xvalloc instead of valloc in our code.

Signed-off-by: Bingpeng Zhu <bingpeng....@alibaba-inc.com>
---
 sheep/plain_store.c |    4 +---
 sheep/request.c     |    6 +-----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 876582c..7ab0699 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -691,9 +691,7 @@ int default_get_hash(uint64_t oid, uint32_t epoch, uint8_t 
*sha1)
        }
 
        length = get_store_objsize(oid);
-       buf = valloc(length);
-       if (buf == NULL)
-               return SD_RES_NO_MEM;
+       buf = xvalloc(length);
 
        iocb.epoch = epoch;
        iocb.buf = buf;
diff --git a/sheep/request.c b/sheep/request.c
index 8a2e7dc..bc10b90 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -690,11 +690,7 @@ static struct request *alloc_request(struct client_info 
*ci, int data_length)
 
        if (data_length) {
                req->data_length = data_length;
-               req->data = valloc(data_length);
-               if (!req->data) {
-                       free(req);
-                       return NULL;
-               }
+               req->data = xvalloc(data_length);
        }
 
        req->ci = ci;
-- 
1.7.1


-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to