From owner-svn-src-all@FreeBSD.ORG Fri Jun 20 15:29:10 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6F3B01FC; Fri, 20 Jun 2014 15:29:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 427C22C9A; Fri, 20 Jun 2014 15:29:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5KFTAq0068039; Fri, 20 Jun 2014 15:29:10 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5KFTAEB068038; Fri, 20 Jun 2014 15:29:10 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201406201529.s5KFTAEB068038@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Fri, 20 Jun 2014 15:29:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267675 - head/lib/libc/regex X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2014 15:29:10 -0000 Author: pfg Date: Fri Jun 20 15:29:09 2014 New Revision: 267675 URL: http://svnweb.freebsd.org/changeset/base/267675 Log: regex: Make use of reallocf(). Use of reallocf is useful in libraries as we are not certain the application will exit after NULL. This somewhat reduces portability but if since you are building this as part of libc it is likely you have our non-standard reallocf(3) already. Reviewed by: ache MFC after: 5 days Modified: head/lib/libc/regex/regcomp.c Modified: head/lib/libc/regex/regcomp.c ============================================================================== --- head/lib/libc/regex/regcomp.c Fri Jun 20 13:26:49 2014 (r267674) +++ head/lib/libc/regex/regcomp.c Fri Jun 20 15:29:09 2014 (r267675) @@ -1111,7 +1111,7 @@ allocset(struct parse *p) { cset *cs, *ncs; - ncs = realloc(p->g->sets, (p->g->ncsets + 1) * sizeof(*ncs)); + ncs = reallocf(p->g->sets, (p->g->ncsets + 1) * sizeof(*ncs)); if (ncs == NULL) { SETERROR(REG_ESPACE); return (NULL); @@ -1174,7 +1174,7 @@ CHadd(struct parse *p, cset *cs, wint_t if (ch < NC) cs->bmp[ch >> 3] |= 1 << (ch & 7); else { - newwides = realloc(cs->wides, (cs->nwides + 1) * + newwides = reallocf(cs->wides, (cs->nwides + 1) * sizeof(*cs->wides)); if (newwides == NULL) { SETERROR(REG_ESPACE); @@ -1203,7 +1203,7 @@ CHaddrange(struct parse *p, cset *cs, wi CHadd(p, cs, min); if (min >= max) return; - newranges = realloc(cs->ranges, (cs->nranges + 1) * + newranges = reallocf(cs->ranges, (cs->nranges + 1) * sizeof(*cs->ranges)); if (newranges == NULL) { SETERROR(REG_ESPACE); @@ -1227,7 +1227,7 @@ CHaddtype(struct parse *p, cset *cs, wct for (i = 0; i < NC; i++) if (iswctype(i, wct)) CHadd(p, cs, i); - newtypes = realloc(cs->types, (cs->ntypes + 1) * + newtypes = reallocf(cs->types, (cs->ntypes + 1) * sizeof(*cs->types)); if (newtypes == NULL) { SETERROR(REG_ESPACE); @@ -1350,7 +1350,7 @@ enlarge(struct parse *p, sopno size) if (p->ssize >= size) return 1; - sp = (sop *)realloc(p->strip, size*sizeof(sop)); + sp = (sop *)reallocf(p->strip, size*sizeof(sop)); if (sp == NULL) { SETERROR(REG_ESPACE); return 0; @@ -1368,7 +1368,7 @@ static void stripsnug(struct parse *p, struct re_guts *g) { g->nstates = p->slen; - g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop)); + g->strip = (sop *)reallocf((char *)p->strip, p->slen * sizeof(sop)); if (g->strip == NULL) { SETERROR(REG_ESPACE); g->strip = p->strip;