Browse Source

use eina_strndup() instead of the GNU extension strndup(). Fix also a warning with CreateFile()

master
Vincent Torri 3 years ago committed by Hermet Park
parent
commit
724cd0d040
  1. 1
      .gitignore
  2. 2
      src/bin/edc_navigator.c
  3. 16
      src/bin/live_edit.c
  4. 2
      src/bin/main.c
  5. 4
      src/lib/edc_editor.c
  6. 4
      src/lib/edc_parser.c
  7. 14
      src/lib/reference.c
  8. 4
      src/lib/syntax_color.c

1
.gitignore vendored

@ -4,6 +4,7 @@
*.edj
*.swp
*.eet
*.exe
*~
.*
*.eo.*

2
src/bin/edc_navigator.c

@ -733,7 +733,7 @@ states_update(navi_data *nd, part_it *pit)
sit->tag.idx = idx;
//Parsing "default" "0.00". We don't take care 0.00 in the state name.
const char *brk = strpbrk(name, " ");
if (brk) sit->name = strndup(name, brk - name);
if (brk) sit->name = eina_strndup(name, brk - name);
else sit->name = strdup(name);
sit->pit = pit;

16
src/bin/live_edit.c

@ -397,7 +397,7 @@ calc_relative_info(live_data *ld)
ld->rel_to_info.align_x = 0.0;
ld->rel_to_info.rel2_x = ld->rel_to_info.rel1_x;
free(ld->rel_to_info.rel2_x_part);
ld->rel_to_info.rel2_x_part = strndup(ld->rel_to_info.rel1_x_part,
ld->rel_to_info.rel2_x_part = eina_strndup(ld->rel_to_info.rel1_x_part,
strlen(ld->rel_to_info.rel1_x_part));
}
else if (ld->rel_to_info.rel2_x_part)
@ -405,7 +405,7 @@ calc_relative_info(live_data *ld)
ld->rel_to_info.align_x = 1.0;
ld->rel_to_info.rel1_x = ld->rel_to_info.rel2_x;
free(ld->rel_to_info.rel1_x_part);
ld->rel_to_info.rel1_x_part = strndup(ld->rel_to_info.rel2_x_part,
ld->rel_to_info.rel1_x_part = eina_strndup(ld->rel_to_info.rel2_x_part,
strlen(ld->rel_to_info.rel2_x_part));
}
else
@ -433,7 +433,7 @@ calc_relative_info(live_data *ld)
ld->rel_to_info.align_y = 0.0;
ld->rel_to_info.rel2_y = ld->rel_to_info.rel1_y;
free(ld->rel_to_info.rel2_y_part);
ld->rel_to_info.rel2_y_part = strndup(ld->rel_to_info.rel1_y_part,
ld->rel_to_info.rel2_y_part = eina_strndup(ld->rel_to_info.rel1_y_part,
strlen(ld->rel_to_info.rel1_y_part));
}
else if (ld->rel_to_info.rel2_y_part)
@ -441,7 +441,7 @@ calc_relative_info(live_data *ld)
ld->rel_to_info.align_y = 1.0;
ld->rel_to_info.rel1_y = ld->rel_to_info.rel2_y;
free(ld->rel_to_info.rel1_y_part);
ld->rel_to_info.rel1_y_part = strndup(ld->rel_to_info.rel2_y_part,
ld->rel_to_info.rel1_y_part = eina_strndup(ld->rel_to_info.rel2_y_part,
strlen(ld->rel_to_info.rel2_y_part));
}
else
@ -1249,7 +1249,7 @@ rel_to_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
(ld->last_cp == Ctrl_Pt_Left))
{
free(ld->rel_to_info.rel1_x_part);
ld->rel_to_info.rel1_x_part = strndup(rel_data->part_name,
ld->rel_to_info.rel1_x_part = eina_strndup(rel_data->part_name,
strlen(rel_data->part_name));
ld->rel_to_info.rel1_x = rel_data->rel_x;
}
@ -1259,7 +1259,7 @@ rel_to_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
(ld->last_cp == Ctrl_Pt_Right))
{
free(ld->rel_to_info.rel2_x_part);
ld->rel_to_info.rel2_x_part = strndup(rel_data->part_name,
ld->rel_to_info.rel2_x_part = eina_strndup(rel_data->part_name,
strlen(rel_data->part_name));
ld->rel_to_info.rel2_x = rel_data->rel_x;
}
@ -1284,7 +1284,7 @@ rel_to_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
(ld->last_cp == Ctrl_Pt_Top))
{
free(ld->rel_to_info.rel1_y_part);
ld->rel_to_info.rel1_y_part = strndup(rel_data->part_name,
ld->rel_to_info.rel1_y_part = eina_strndup(rel_data->part_name,
strlen(rel_data->part_name));
ld->rel_to_info.rel1_y = rel_data->rel_y;
}
@ -1294,7 +1294,7 @@ rel_to_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
(ld->last_cp == Ctrl_Pt_Bottom))
{
free(ld->rel_to_info.rel2_y_part);
ld->rel_to_info.rel2_y_part = strndup(rel_data->part_name,
ld->rel_to_info.rel2_y_part = eina_strndup(rel_data->part_name,
strlen(rel_data->part_name));
ld->rel_to_info.rel2_y = rel_data->rel_y;
}

2
src/bin/main.c

@ -969,7 +969,7 @@ enventor_lock_create(void)
#ifdef _WIN32
hMutex = CreateMutex(NULL, FALSE, ENVENTOR_NAME);
HANDLE handle = CreateFile(buf, GENERIC_READ, NULL, NULL, CREATE_NEW,
HANDLE handle = CreateFile(buf, GENERIC_READ, 0, NULL, CREATE_NEW,
FILE_FLAG_DELETE_ON_CLOSE, 0);
if (INVALID_HANDLE_VALUE == handle)
{

4
src/lib/edc_editor.c

@ -1049,7 +1049,7 @@ edit_quick_jump(edit_data *ed)
name_begin++;
char *name_end = strstr(name_begin, "\"");
if (!name_end) goto end;
file_link = strndup(name_begin, name_end - name_begin);
file_link = eina_strndup(name_begin, name_end - name_begin);
if (file_link)
{
//Compose the absolute file path.
@ -1057,7 +1057,7 @@ edit_quick_jump(edit_data *ed)
if (!file_name) goto end;
char *file_path =
strndup(ed->filepath, (file_name - ed->filepath));
eina_strndup(ed->filepath, (file_name - ed->filepath));
if (!file_path) goto end;
char buf[PATH_MAX];

4
src/lib/edc_parser.c

@ -1431,7 +1431,7 @@ parser_name_get(parser_data *pd EINA_UNUSED, const char *cur)
char *eol = strstr(cur, "\n");
if (eol && (eol < p)) return NULL;
return strndup(p, (end - p));
return eina_strndup(p, (end - p));
}
attr_value *
@ -1864,7 +1864,7 @@ parser_states_filtered_name_get(Eina_List *states)
pp = p;
p++;
}
ret = eina_list_append(ret, strndup(state, pp - state));
ret = eina_list_append(ret, eina_strndup(state, pp - state));
}
return ret;
}

14
src/lib/reference.c

@ -143,7 +143,7 @@ cursor_keyword_name_find(Evas_Object *entry)
cur_ptr++;
}
keyword_name = strndup(cur_begin_ptr, (cur_end_ptr - cur_begin_ptr + 1));
keyword_name = eina_strndup(cur_begin_ptr, (cur_end_ptr - cur_begin_ptr + 1));
end:
if (cur_begin) evas_textblock_cursor_free(cur_begin);
@ -217,7 +217,7 @@ keyword_hierarchy_find(const char *text, const char *keyword_name)
if (parent_end && !parent_begin)
parent_begin = text;
char *parent_name = strndup(parent_begin,
char *parent_name = eina_strndup(parent_begin,
(parent_end - parent_begin + 1));
keyword_hierarchy = eina_list_prepend(keyword_hierarchy,
parent_name);
@ -357,7 +357,7 @@ keyword_full_name_parse(const char *keyword_full_name)
char *dot = strstr(keyword_full_name, ".");
while (dot)
{
keyword_name = strndup(keyword_begin, (dot - keyword_begin));
keyword_name = eina_strndup(keyword_begin, (dot - keyword_begin));
keyword_hierarchy = eina_list_append(keyword_hierarchy, keyword_name);
keyword_begin = dot + 1; //Move pointer after ".".
@ -369,7 +369,7 @@ keyword_full_name_parse(const char *keyword_full_name)
keyword_hierarchy =
eina_list_append(keyword_hierarchy,
strndup(keyword_begin, (keyword_end - keyword_begin)));
eina_strndup(keyword_begin, (keyword_end - keyword_begin)));
return keyword_hierarchy;
}
@ -400,7 +400,7 @@ inherit_find(const char *text_begin, const char *text_end, char **inherit_end)
base_keyword_end--;
base_keyword_full_name =
strndup((const char *)base_keyword_begin,
eina_strndup((const char *)base_keyword_begin,
(base_keyword_end - base_keyword_begin + 1));
//Indicates the ending position of #inherit expression.
@ -457,7 +457,7 @@ keyword_tree_load_internal(keyword_data *keyword_root, char **ptr,
}
if (!keyword_name_begin || !keyword_name_end) break;
keyword_name = strndup(keyword_name_begin,
keyword_name = eina_strndup(keyword_name_begin,
(keyword_name_end - keyword_name_begin + 1));
if (!keyword_name) break;
(*ptr)++; //Move pointer after "{".
@ -483,7 +483,7 @@ keyword_tree_load_internal(keyword_data *keyword_root, char **ptr,
keyword_desc_end--;
keyword_desc =
strndup((const char *)keyword_desc_begin,
eina_strndup((const char *)keyword_desc_begin,
(keyword_desc_end - keyword_desc_begin + 1));
if (!keyword_desc)

4
src/lib/syntax_color.c

@ -189,7 +189,7 @@ macro_key_push(color_data *cd, char *str)
char *cut = strchr(key, '(');
if (cut)
{
key = strndup(str, cut - str);
key = eina_strndup(str, cut - str);
if (!key) return;
}
@ -474,7 +474,7 @@ macro_apply(Eina_Strbuf *strbuf, const char **src, int length, char **cur,
if ((macro_end > macro_begin) &&
((macro_begin[0] < '0') || (macro_begin[0] > '9')))
{
char *macro = strndup(macro_begin, (macro_end - macro_begin));
char *macro = eina_strndup(macro_begin, (macro_end - macro_begin));
macro_key_push(cd, macro);
free(macro);
}

Loading…
Cancel
Save