From 2d8da282065a758ac930bf203387ddd73e0bd129 Mon Sep 17 00:00:00 2001 From: kris Date: Sun, 25 Feb 2007 15:59:32 +0000 Subject: [PATCH] Remove Lmalloc() from nse_pcrelib.cc and change the only call to it to safe_malloc(). I noticed this when I was doing r4515 but wanted to check it a little further; Lmalloc() calls safe_malloc(), and then tests the returned mem == NULL and returns the mem, but this will never happen because safe_malloc() dies if the mem is NULL. --- nse_pcrelib.cc | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/nse_pcrelib.cc b/nse_pcrelib.cc index 69387319d..2b68406c1 100644 --- a/nse_pcrelib.cc +++ b/nse_pcrelib.cc @@ -29,15 +29,6 @@ static void L_lua_error(lua_State *L, const char *message) status = lua_error(L); } -static void *Lmalloc(lua_State *L, size_t size) -{ - void *p = safe_malloc(size); - if(p == NULL) - L_lua_error(L, "malloc failed"); - - return p; -} - static int get_startoffset(lua_State *L, int stackpos, size_t len) { int startoffset = luaL_optint(L, stackpos, 1); @@ -159,7 +150,7 @@ static int Lpcre_comp(lua_State *L) pcre_fullinfo(ud->pr, ud->extra, PCRE_INFO_CAPTURECOUNT, &ud->ncapt); /* need (2 ints per capture, plus one for substring match) * 3/2 */ - ud->match = (int *) Lmalloc(L, (ud->ncapt + 1) * 3 * sizeof(int)); + ud->match = (int *) safe_malloc((ud->ncapt + 1) * 3 * sizeof(int)); return 1; }