|
|
836b22 |
From f6d20a58183d7a7ab20033a87ddd60798e809f80 Mon Sep 17 00:00:00 2001
|
|
|
836b22 |
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
836b22 |
Date: Mon, 28 Jan 2019 19:23:46 +0100
|
|
|
836b22 |
Subject: [PATCH 4/9] providers/proxy: got rid of excessive mem copies
|
|
|
836b22 |
MIME-Version: 1.0
|
|
|
836b22 |
Content-Type: text/plain; charset=UTF-8
|
|
|
836b22 |
Content-Transfer-Encoding: 8bit
|
|
|
836b22 |
|
|
|
836b22 |
There is no need to create copies of strings for temporary storage
|
|
|
836b22 |
in hash_table.
|
|
|
836b22 |
|
|
|
836b22 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
836b22 |
(cherry picked from commit 29ac739ee186bab2e3a0111fcc8f43cb70401b42)
|
|
|
836b22 |
|
|
|
836b22 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
836b22 |
---
|
|
|
836b22 |
src/providers/proxy/proxy_id.c | 17 ++++-------------
|
|
|
836b22 |
1 file changed, 4 insertions(+), 13 deletions(-)
|
|
|
836b22 |
|
|
|
836b22 |
diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
|
|
|
836b22 |
index 52f7a6424..3e8a43ad7 100644
|
|
|
836b22 |
--- a/src/providers/proxy/proxy_id.c
|
|
|
836b22 |
+++ b/src/providers/proxy/proxy_id.c
|
|
|
836b22 |
@@ -620,24 +620,15 @@ static errno_t remove_duplicate_group_members(TALLOC_CTX *mem_ctx,
|
|
|
836b22 |
|
|
|
836b22 |
for (i=0; i < orig_member_count; ++i) {
|
|
|
836b22 |
key.type = HASH_KEY_STRING;
|
|
|
836b22 |
- key.str = talloc_strdup(member_tbl, orig_grp->gr_mem[i]);
|
|
|
836b22 |
- if (key.str == NULL) {
|
|
|
836b22 |
- DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
|
|
|
836b22 |
- ret = ENOMEM;
|
|
|
836b22 |
- goto done;
|
|
|
836b22 |
- }
|
|
|
836b22 |
+ key.str = orig_grp->gr_mem[i]; /* hash_enter() makes copy itself */
|
|
|
836b22 |
|
|
|
836b22 |
value.type = HASH_VALUE_PTR;
|
|
|
836b22 |
- value.ptr = talloc_strdup(member_tbl, orig_grp->gr_mem[i]);
|
|
|
836b22 |
- if (value.ptr == NULL) {
|
|
|
836b22 |
- DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
|
|
|
836b22 |
- ret = ENOMEM;
|
|
|
836b22 |
- goto done;
|
|
|
836b22 |
- }
|
|
|
836b22 |
+ /* no need to put copy in hash_table since
|
|
|
836b22 |
+ copy will be created during construction of new grp */
|
|
|
836b22 |
+ value.ptr = orig_grp->gr_mem[i];
|
|
|
836b22 |
|
|
|
836b22 |
ret = hash_enter(member_tbl, &key, &value);
|
|
|
836b22 |
if (ret != HASH_SUCCESS) {
|
|
|
836b22 |
- talloc_free(key.str);
|
|
|
836b22 |
ret = ENOMEM;
|
|
|
836b22 |
goto done;
|
|
|
836b22 |
}
|
|
|
836b22 |
--
|
|
|
836b22 |
2.21.1
|
|
|
836b22 |
|