From c59b4880e4b14979d562ae10b6365546a9b98242 Mon Sep 17 00:00:00 2001
From: Mooffie <mooffie@gmail.com>
Date: Mon, 26 Sep 2016 00:51:22 +0300
Subject: [PATCH 7/8] (mc_search__hex_translate_to_regex): avoid string
duplication.
We can read from the source string directly, as we no longer modify it.
---
lib/search/hex.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/search/hex.c b/lib/search/hex.c
index 14d0246..a0a3c19 100644
a
|
b
|
mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err |
58 | 58 | int *error_pos_ptr) |
59 | 59 | { |
60 | 60 | GString *buff; |
61 | | gchar *tmp_str; |
| 61 | const char *tmp_str; |
62 | 62 | gsize tmp_str_len; |
63 | 63 | gsize loop = 0; |
64 | 64 | mc_search_hex_parse_error_t error = MC_SEARCH_HEX_E_OK; |
65 | 65 | |
66 | 66 | buff = g_string_sized_new (64); |
67 | | tmp_str = g_strndup (astr->str, astr->len); |
68 | | tmp_str_len = strlen (tmp_str); |
| 67 | tmp_str = astr->str; |
| 68 | tmp_str_len = astr->len; |
69 | 69 | |
70 | 70 | while (loop < tmp_str_len && error == MC_SEARCH_HEX_E_OK) |
71 | 71 | { |
… |
… |
mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err |
119 | 119 | error = MC_SEARCH_HEX_E_INVALID_CHARACTER; |
120 | 120 | } |
121 | 121 | |
122 | | g_free (tmp_str); |
123 | | |
124 | 122 | if (error != MC_SEARCH_HEX_E_OK) |
125 | 123 | { |
126 | 124 | g_string_free (buff, TRUE); |