1
1

Use g_strndup() instead of g_strdup()

...to ret rid of extra calculation of string length.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2012-08-31 13:07:20 +04:00 коммит произвёл Slava Zanko
родитель 5e1ae44eca
Коммит 8b382756bf
4 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -210,7 +210,7 @@ history_load (struct mc_config_t * cfg, const char *name)
hist = list_append_unique (hist, this_entry);
else
{
hist = list_append_unique (hist, g_strdup (buffer->str));
hist = list_append_unique (hist, g_strndup (buffer->str, buffer->len));
g_free (this_entry);
}
}

Просмотреть файл

@ -1280,7 +1280,7 @@ edit_collect_completions (WEdit * edit, off_t word_start, gsize word_len,
g_string_free (recoded, TRUE);
}
#endif
compl[*num].text = g_strdup (temp->str);
compl[*num].text = g_strndup (temp->str, temp->len);
compl[*num].len = temp->len;
(*num)++;
start += len;

Просмотреть файл

@ -1426,7 +1426,8 @@ hot_load_group (struct hotlist *grp)
case TKN_GROUP:
CHECK_TOKEN (TKN_STRING);
new_grp =
add2hotlist (g_strdup (tkn_buf->str), 0, HL_TYPE_GROUP, LISTBOX_APPEND_AT_END);
add2hotlist (g_strndup (tkn_buf->str, tkn_buf->len), 0, HL_TYPE_GROUP,
LISTBOX_APPEND_AT_END);
SKIP_TO_EOL;
hot_load_group (new_grp);
current_group = grp;
@ -1434,7 +1435,7 @@ hot_load_group (struct hotlist *grp)
case TKN_ENTRY:
{
CHECK_TOKEN (TKN_STRING);
label = g_strdup (tkn_buf->str);
label = g_strndup (tkn_buf->str, tkn_buf->len);
CHECK_TOKEN (TKN_URL);
CHECK_TOKEN (TKN_STRING);
url = tilde_expand (tkn_buf->str);
@ -1443,7 +1444,7 @@ hot_load_group (struct hotlist *grp)
}
break;
case TKN_COMMENT:
label = g_strdup (tkn_buf->str);
label = g_strndup (tkn_buf->str, tkn_buf->len);
add2hotlist (label, 0, HL_TYPE_COMMENT, LISTBOX_APPEND_AT_END);
break;
case TKN_EOF:
@ -1480,7 +1481,8 @@ hot_load_file (struct hotlist *grp)
case TKN_GROUP:
CHECK_TOKEN (TKN_STRING);
new_grp =
add2hotlist (g_strdup (tkn_buf->str), 0, HL_TYPE_GROUP, LISTBOX_APPEND_AT_END);
add2hotlist (g_strndup (tkn_buf->str, tkn_buf->len), 0, HL_TYPE_GROUP,
LISTBOX_APPEND_AT_END);
SKIP_TO_EOL;
hot_load_group (new_grp);
current_group = grp;
@ -1488,7 +1490,7 @@ hot_load_file (struct hotlist *grp)
case TKN_ENTRY:
{
CHECK_TOKEN (TKN_STRING);
label = g_strdup (tkn_buf->str);
label = g_strndup (tkn_buf->str, tkn_buf->len);
CHECK_TOKEN (TKN_URL);
CHECK_TOKEN (TKN_STRING);
url = tilde_expand (tkn_buf->str);
@ -1497,7 +1499,7 @@ hot_load_file (struct hotlist *grp)
}
break;
case TKN_COMMENT:
label = g_strdup (tkn_buf->str);
label = g_strndup (tkn_buf->str, tkn_buf->len);
add2hotlist (label, 0, HL_TYPE_COMMENT, LISTBOX_APPEND_AT_END);
break;
case TKN_EOL:

Просмотреть файл

@ -4570,7 +4570,7 @@ remove_encoding_from_path (const vfs_path_t * vpath)
str_vfs_convert_from (converter, path_element->path, tmp_conv);
g_free (path_element->path);
path_element->path = g_strdup (tmp_conv->str);
path_element->path = g_strndup (tmp_conv->str, tmp_conv->len);
g_string_set_size (tmp_conv, 0);