Mercurial > hg > Applications > Grep
diff c/regexParser/createBitVectorList.cc @ 108:70069d4647a0 impl-bitvector
implement malloc error checking
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 19 Nov 2015 17:48:36 +0900 |
parents | c9f5ee891b5e |
children | 6401c708f5dd |
line wrap: on
line diff
--- a/c/regexParser/createBitVectorList.cc Thu Nov 19 17:23:06 2015 +0900 +++ b/c/regexParser/createBitVectorList.cc Thu Nov 19 17:48:36 2015 +0900 @@ -14,8 +14,18 @@ BitVectorListPtr allocateBitVectorList() { BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); + if (bvl == NULL) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(-1); + } + bvl->self = bvl; bvl->bi = (BitVectorPtr)malloc(sizeof(BitVector)); + if (bvl->bi == NULL) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(-1); + } + return bvl; }