From nobody Wed Oct 19 08:01:23 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Msjq74sCyz4gDJb; Wed, 19 Oct 2022 08:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Msjq73x5pz3xg7; Wed, 19 Oct 2022 08:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666166483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UZzgH4h2QtQu4kuy1vCKr5XVx1HHjrGDI4PUylL0jKk=; b=XTumE3UszFvEmc8/aYAU8JThJ8WL+rj0rTLCTy/jATOetjhpMgwQvFJtjxe4Ow6rs4fLuQ wxxsTOH1bKAwV+cXgDMa9FvDJirJYfSmjhyuEbQIiGiz63CmPsjF3AXgDDUF0LmexDxTL8 vkPPdH+AYRw79Kyt3bQOVMZUqIioOSkx8unKs/vKfaKbRSIGYCuhUAwEBuUBMv33NBVkD6 y1R8N5RwvMXv92EMjgFu9lFrn6QR0kfRRSPOBwCBeWyq8SjOheqa5WMcmtDWYkJgzhHvY4 lTokh8ZXCbRF2tcBrdU6Gix5xwqPf4lG+t0uBgm5nc1pF09Fph2DF0faqfjGQQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Msjq730XLzSTJ; Wed, 19 Oct 2022 08:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29J81NN0060550; Wed, 19 Oct 2022 08:01:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29J81NlA060549; Wed, 19 Oct 2022 08:01:23 GMT (envelope-from git) Date: Wed, 19 Oct 2022 08:01:23 GMT Message-Id: <202210190801.29J81NlA060549@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 47204fd342e8 - stable/13 - sort: replace malloc+memset with calloc List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 47204fd342e8875c330d8c217e8261a2fb0f68f1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666166483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UZzgH4h2QtQu4kuy1vCKr5XVx1HHjrGDI4PUylL0jKk=; b=ZuNh5rComwT2EzElVauMhvqBnUthYps/AAhUUolQB5K7J7oxr2NZsMA2+eVZNGDWFhFnkO x/bz2aOWTJrvMYKH/RuOMJFdF6N7aZdAOSKtbkK56DitZUKu4hsVVJOrZWQgulsRFIUE5C eRinMKyCTVfvJOl9dQ6k6cBReetmTqt4fnknNaEXclXgq9eiYA/UHyDcC2tZrTTaoVWnfj jBT6eSyLYrjCgCOvYziA13yO0ZdIPpiD0/OSI1imOwl12UzrkZrfHZHmTJ/xrHEzRHVDGP C/DtCaz+nupXQZjoHWwTHYvWw9h/kYwbpZMmcAkcP8yICqHJ1gDM+Rw3b1yoKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666166483; a=rsa-sha256; cv=none; b=OoDn7TkXpzuaY+pEQKuPv4pO6uwo4PQFoMZD8gem7js68F6MpDJLE6XypTCRKB1Ur9zi1N f/0VqJASE1E6RRmkGyP+jvYwvUt6kkjhySZRqhrz1/4ZPmOR8k7xV+1FRTNemNhaabf+DR GdEUsn3hsai8kWP/bCwc0OPPoZKGNIkPvEO7xKwdgANEF/C5N5T48DNN+mhC6Ut1n997PZ 9CuWUxstn7mUekdY+F3KnR9Owlcu6BTgIj0RpLjue7Mp0cHC/ewGr6Il6xPhF5etWrGppA SzZrYvE6okypUNm8updx3UZr+083IXDcAlHZGuXYrMEW3v1tqBpR1jJRT3j94A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=47204fd342e8875c330d8c217e8261a2fb0f68f1 commit 47204fd342e8875c330d8c217e8261a2fb0f68f1 Author: Baptiste Daroussin AuthorDate: 2022-10-12 13:57:11 +0000 Commit: Baptiste Daroussin CommitDate: 2022-10-19 07:56:50 +0000 sort: replace malloc+memset with calloc (cherry picked from commit ecc3c2916751a0aef5619ed8f0ba1cc37c0a22ba) --- usr.bin/sort/coll.c | 6 ++---- usr.bin/sort/file.c | 3 +-- usr.bin/sort/radixsort.c | 12 ++++-------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/usr.bin/sort/coll.c b/usr.bin/sort/coll.c index ccd73e19d393..e3d388743d4a 100644 --- a/usr.bin/sort/coll.c +++ b/usr.bin/sort/coll.c @@ -73,8 +73,7 @@ keys_array_alloc(void) size_t sz; sz = keys_array_size(); - ka = sort_malloc(sz); - memset(ka, 0, sz); + ka = sort_calloc(1, sz); return (ka); } @@ -157,8 +156,7 @@ sort_list_item_alloc(void) size_t sz; sz = sizeof(struct sort_list_item) + keys_array_size(); - si = sort_malloc(sz); - memset(si, 0, sz); + si = sort_calloc(1, sz); return (si); } diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c index b6b9d934e0ef..1fb02642b5c9 100644 --- a/usr.bin/sort/file.c +++ b/usr.bin/sort/file.c @@ -615,8 +615,7 @@ file_reader_init(const char *fsrc) if (fsrc == NULL) fsrc = "-"; - ret = sort_malloc(sizeof(struct file_reader)); - memset(ret, 0, sizeof(struct file_reader)); + ret = sort_calloc(1, sizeof(struct file_reader)); ret->elsymb = '\n'; if (sort_opts_vals.zflag) diff --git a/usr.bin/sort/radixsort.c b/usr.bin/sort/radixsort.c index 4c448fad69e9..578493f4d47c 100644 --- a/usr.bin/sort/radixsort.c +++ b/usr.bin/sort/radixsort.c @@ -225,8 +225,7 @@ add_to_sublevel(struct sort_level *sl, struct sort_list_item *item, size_t indx) ssl = sl->sublevels[indx]; if (ssl == NULL) { - ssl = sort_malloc(sizeof(struct sort_level)); - memset(ssl, 0, sizeof(struct sort_level)); + ssl = sort_calloc(1, sizeof(struct sort_level)); ssl->level = sl->level + 1; sl->sublevels[indx] = ssl; @@ -416,8 +415,7 @@ run_sort_level_next(struct sort_level *sl) } sl->sln = 256; - sl->sublevels = sort_malloc(slsz); - memset(sl->sublevels, 0, slsz); + sl->sublevels = sort_calloc(1, slsz); sl->real_sln = 0; @@ -569,8 +567,7 @@ run_top_sort_level(struct sort_level *sl) sl->start_position = 0; sl->sln = 256; - sl->sublevels = sort_malloc(slsz); - memset(sl->sublevels, 0, slsz); + sl->sublevels = sort_calloc(1, slsz); for (size_t i = 0; i < sl->tosort_num; ++i) place_item(sl, i); @@ -696,8 +693,7 @@ run_sort(struct sort_list_item **base, size_t nmemb) } #endif - sl = sort_malloc(sizeof(struct sort_level)); - memset(sl, 0, sizeof(struct sort_level)); + sl = sort_calloc(1, sizeof(struct sort_level)); sl->tosort = base; sl->tosort_num = nmemb;