From owner-svn-src-stable-11@freebsd.org Wed Aug 16 00:24:00 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B175DDD8178; Wed, 16 Aug 2017 00:24:00 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 881E4667AA; Wed, 16 Aug 2017 00:24:00 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7G0NxAi029803; Wed, 16 Aug 2017 00:23:59 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0NxG3029799; Wed, 16 Aug 2017 00:23:59 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160023.v7G0NxG3029799@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:23:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322557 - in stable/11/usr.bin/grep: . regex X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/usr.bin/grep: . regex X-SVN-Commit-Revision: 322557 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Aug 2017 00:24:00 -0000 Author: kevans Date: Wed Aug 16 00:23:59 2017 New Revision: 322557 URL: https://svnweb.freebsd.org/changeset/base/322557 Log: MFC r316492: bsdgrep(1): Rip out "xmalloc" bits xmalloc was a debug malloc implementation, but the x{malloc,calloc,free} functions default to calling the malloc(3) equivalents. Instead of relying on this malloc shim, we can devise better ways to debug malloc issues that aren't misleading upon initial inspection. (I.e., using jemalloc's various built-in debugging capabilities.) Approved by: emaste (mentor, blanket MFC) Deleted: stable/11/usr.bin/grep/regex/xmalloc.c stable/11/usr.bin/grep/regex/xmalloc.h Modified: stable/11/usr.bin/grep/Makefile stable/11/usr.bin/grep/regex/fastmatch.c stable/11/usr.bin/grep/regex/tre-compile.c stable/11/usr.bin/grep/regex/tre-fastmatch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/Makefile ============================================================================== --- stable/11/usr.bin/grep/Makefile Wed Aug 16 00:19:59 2017 (r322556) +++ stable/11/usr.bin/grep/Makefile Wed Aug 16 00:23:59 2017 (r322557) @@ -17,7 +17,7 @@ SRCS= file.c grep.c queue.c util.c # Extra files ported backported form some regex improvements .PATH: ${.CURDIR}/regex -SRCS+= fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c xmalloc.c +SRCS+= fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c CFLAGS+=-I${.CURDIR}/regex CFLAGS.gcc+= --param max-inline-insns-single=500 Modified: stable/11/usr.bin/grep/regex/fastmatch.c ============================================================================== --- stable/11/usr.bin/grep/regex/fastmatch.c Wed Aug 16 00:19:59 2017 (r322556) +++ stable/11/usr.bin/grep/regex/fastmatch.c Wed Aug 16 00:23:59 2017 (r322557) @@ -34,7 +34,6 @@ #include #include "tre-fastmatch.h" -#include "xmalloc.h" int tre_fixncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) Modified: stable/11/usr.bin/grep/regex/tre-compile.c ============================================================================== --- stable/11/usr.bin/grep/regex/tre-compile.c Wed Aug 16 00:19:59 2017 (r322556) +++ stable/11/usr.bin/grep/regex/tre-compile.c Wed Aug 16 00:23:59 2017 (r322557) @@ -9,8 +9,6 @@ #include #include -#include "xmalloc.h" - int tre_convert_pattern(const char *regex, size_t n, tre_char_t **w, size_t *wn) @@ -19,7 +17,7 @@ tre_convert_pattern(const char *regex, size_t n, tre_c tre_char_t *wregex; size_t wlen; - wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); + wregex = malloc(sizeof(tre_char_t) * (n + 1)); if (wregex == NULL) return REG_ESPACE; @@ -60,13 +58,13 @@ tre_convert_pattern(const char *regex, size_t n, tre_c consumed = 1; else { - xfree(wregex); + free(wregex); return REG_BADPAT; } break; case -1: DPRINT(("mbrtowc: error %d: %s.\n", errno, strerror(errno))); - xfree(wregex); + free(wregex); return REG_BADPAT; case -2: /* The last character wasn't complete. Let's not call it a @@ -98,6 +96,6 @@ void tre_free_pattern(tre_char_t *wregex) { #if TRE_WCHAR - xfree(wregex); + free(wregex); #endif } Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c ============================================================================== --- stable/11/usr.bin/grep/regex/tre-fastmatch.c Wed Aug 16 00:19:59 2017 (r322556) +++ stable/11/usr.bin/grep/regex/tre-fastmatch.c Wed Aug 16 00:23:59 2017 (r322557) @@ -42,7 +42,6 @@ #include "hashtable.h" #include "tre-fastmatch.h" -#include "xmalloc.h" static int fastcmp(const fastmatch_t *fg, const void *data, tre_str_type_t type); @@ -53,9 +52,9 @@ static int fastcmp(const fastmatch_t *fg, const void * #define FAIL_COMP(errcode) \ { \ if (fg->pattern) \ - xfree(fg->pattern); \ + free(fg->pattern); \ if (fg->wpattern) \ - xfree(fg->wpattern); \ + free(fg->wpattern); \ if (fg->qsBc_table) \ hashtable_free(fg->qsBc_table); \ fg = NULL; \ @@ -92,7 +91,7 @@ static int fastcmp(const fastmatch_t *fg, const void * if (siz == (size_t)-1) \ return REG_BADPAT; \ fg->len = siz; \ - fg->pattern = xmalloc(siz + 1); \ + fg->pattern = malloc(siz + 1); \ if (fg->pattern == NULL) \ return REG_ESPACE; \ wcstombs(fg->pattern, fg->wpattern, siz); \ @@ -340,7 +339,7 @@ static int fastcmp(const fastmatch_t *fg, const void * #define FILL_BMGS \ if (!fg->hasdot) \ { \ - fg->sbmGs = xmalloc(fg->len * sizeof(int)); \ + fg->sbmGs = malloc(fg->len * sizeof(int)); \ if (!fg->sbmGs) \ return REG_ESPACE; \ if (fg->len == 1) \ @@ -356,7 +355,7 @@ static int fastcmp(const fastmatch_t *fg, const void * #define FILL_BMGS_WIDE \ if (!fg->hasdot) \ { \ - fg->bmGs = xmalloc(fg->wlen * sizeof(int)); \ + fg->bmGs = malloc(fg->wlen * sizeof(int)); \ if (!fg->bmGs) \ return REG_ESPACE; \ if (fg->wlen == 1) \ @@ -376,13 +375,13 @@ static int fastcmp(const fastmatch_t *fg, const void * { \ if (fg->icase) \ { \ - wp = xmalloc(plen * sizeof(tre_char_t)); \ + wp = malloc(plen * sizeof(tre_char_t)); \ if (wp == NULL) \ return REG_ESPACE; \ for (unsigned int i = 0; i < plen; i++) \ wp[i] = towlower(pat[i]); \ _CALC_BMGS(arr, wp, plen); \ - xfree(wp); \ + free(wp); \ } \ else \ _CALC_BMGS(arr, pat, plen); \ @@ -391,13 +390,13 @@ static int fastcmp(const fastmatch_t *fg, const void * { \ if (fg->icase) \ { \ - p = xmalloc(plen); \ + p = malloc(plen); \ if (p == NULL) \ return REG_ESPACE; \ for (unsigned int i = 0; i < plen; i++) \ p[i] = tolower((unsigned char)pat[i]); \ _CALC_BMGS(arr, p, plen); \ - xfree(p); \ + free(p); \ } \ else \ _CALC_BMGS(arr, pat, plen); \ @@ -408,7 +407,7 @@ static int fastcmp(const fastmatch_t *fg, const void * { \ int f = 0, g; \ \ - int *suff = xmalloc(plen * sizeof(int)); \ + int *suff = malloc(plen * sizeof(int)); \ if (suff == NULL) \ return REG_ESPACE; \ \ @@ -440,7 +439,7 @@ static int fastcmp(const fastmatch_t *fg, const void * for (unsigned int i = 0; i <= plen - 2; i++) \ arr[plen - 1 - suff[i]] = plen - 1 - i; \ \ - xfree(suff); \ + free(suff); \ } /* @@ -449,7 +448,7 @@ static int fastcmp(const fastmatch_t *fg, const void * */ #define SAVE_PATTERN(src, srclen, dst, dstlen) \ dstlen = srclen; \ - dst = xmalloc((dstlen + 1) * sizeof(tre_char_t)); \ + dst = malloc((dstlen + 1) * sizeof(tre_char_t)); \ if (dst == NULL) \ return REG_ESPACE; \ if (dstlen > 0) \ @@ -489,11 +488,11 @@ static int fastcmp(const fastmatch_t *fg, const void * if (n == 0) \ { \ fg->matchall = true; \ - fg->pattern = xmalloc(sizeof(char)); \ + fg->pattern = malloc(sizeof(char)); \ if (!fg->pattern) \ FAIL_COMP(REG_ESPACE); \ fg->pattern[0] = '\0'; \ - fg->wpattern = xmalloc(sizeof(tre_char_t)); \ + fg->wpattern = malloc(sizeof(tre_char_t)); \ if (!fg->wpattern) \ FAIL_COMP(REG_ESPACE); \ fg->wpattern[0] = TRE_CHAR('\0'); \ @@ -580,7 +579,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pa if (fg->word && (TRE_MB_CUR_MAX > 1)) return REG_BADPAT; - tmp = xmalloc((n + 1) * sizeof(tre_char_t)); + tmp = malloc((n + 1) * sizeof(tre_char_t)); if (tmp == NULL) return REG_ESPACE; @@ -631,10 +630,10 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pa if (escaped) { if (!_escmap) - _escmap = xmalloc(n * sizeof(bool)); + _escmap = malloc(n * sizeof(bool)); if (!_escmap) { - xfree(tmp); + free(tmp); return REG_ESPACE; } _escmap[i] = true; @@ -688,7 +687,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pa } continue; badpat: - xfree(tmp); + free(tmp); DPRINT(("tre_compile_fast: compilation of pattern failed, falling" "back to NFA\n")); return REG_BADPAT; @@ -715,7 +714,7 @@ badpat: { if (fg->wescmap != NULL) { - fg->escmap = xmalloc(fg->len * sizeof(bool)); + fg->escmap = malloc(fg->len * sizeof(bool)); if (!fg->escmap) { tre_free_fast(fg); @@ -746,7 +745,7 @@ badpat: fg->escmap = _escmap; #endif - xfree(tmp); + free(tmp); DPRINT(("tre_compile_fast: pattern: %s, len %zu, bol %c, eol %c, " "icase: %c, word: %c, newline %c\n", fg->pattern, fg->len, @@ -977,16 +976,16 @@ tre_free_fast(fastmatch_t *fg) #ifdef TRE_WCHAR hashtable_free(fg->qsBc_table); if (!fg->hasdot) - xfree(fg->bmGs); + free(fg->bmGs); if (fg->wescmap) - xfree(fg->wescmap); - xfree(fg->wpattern); + free(fg->wescmap); + free(fg->wpattern); #endif if (!fg->hasdot) - xfree(fg->sbmGs); + free(fg->sbmGs); if (fg->escmap) - xfree(fg->escmap); - xfree(fg->pattern); + free(fg->escmap); + free(fg->pattern); } /*