forked from enlightenment/efl
replace strndup with eina_strndup, remove strndup definition in evil and elm_test_dnd
Test Plan: compilation Reviewers: cedric, zmike, raster Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8814
This commit is contained in:
parent
7047a056ab
commit
7db4714db6
|
@ -194,7 +194,7 @@ _atos(const char *prog, const char *bin_dir, const char *bin_name, unsigned long
|
||||||
if ((spaces == func_space_count) && (func_done == EINA_FALSE))
|
if ((spaces == func_space_count) && (func_done == EINA_FALSE))
|
||||||
{
|
{
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
*func_name = strndup(buf, (int)(s - &(buf[0])));
|
*func_name = eina_strndup(buf, (int)(s - &(buf[0])));
|
||||||
func_done = EINA_TRUE;
|
func_done = EINA_TRUE;
|
||||||
}
|
}
|
||||||
else if (*s == '(')
|
else if (*s == '(')
|
||||||
|
@ -208,7 +208,7 @@ _atos(const char *prog, const char *bin_dir, const char *bin_name, unsigned long
|
||||||
else if ((*s == ':') && (func_done == EINA_TRUE))
|
else if ((*s == ':') && (func_done == EINA_TRUE))
|
||||||
{
|
{
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
*file_name = strndup(f1, (int)(s - f1));
|
*file_name = eina_strndup(f1, (int)(s - f1));
|
||||||
s++;
|
s++;
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
s[len - 1] = '\0'; /* Remove the closing parenthesis */
|
s[len - 1] = '\0'; /* Remove the closing parenthesis */
|
||||||
|
@ -266,7 +266,7 @@ bt_input_translate(const char *line, char **comment)
|
||||||
(int)(fileend - filestart), filestart,
|
(int)(fileend - filestart), filestart,
|
||||||
(int)(addrend - addrstart), addrstart,
|
(int)(addrend - addrstart), addrstart,
|
||||||
(int)(baseend - basestart), basestart);
|
(int)(baseend - basestart), basestart);
|
||||||
*comment = strndup(line, addrstart - line);
|
*comment = eina_strndup(line, addrstart - line);
|
||||||
return local;
|
return local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,25 +201,6 @@ _grid_item_getcb(Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *xposret, int
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char *
|
|
||||||
_strndup(const char *str, size_t len)
|
|
||||||
{
|
|
||||||
const char *p;
|
|
||||||
char *ret;
|
|
||||||
size_t slen;
|
|
||||||
|
|
||||||
for (slen = 0, p = str;
|
|
||||||
(slen < len) && (*p);
|
|
||||||
p++, slen++);
|
|
||||||
|
|
||||||
ret = malloc(slen + 1);
|
|
||||||
if (!ret) return NULL;
|
|
||||||
|
|
||||||
if (slen > 0) memcpy(ret, str, slen);
|
|
||||||
ret[slen] = '\0';
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gl_poscb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it, Evas_Coord x, Evas_Coord y, int xposret, int yposret, Elm_Xdnd_Action action EINA_UNUSED)
|
_gl_poscb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it, Evas_Coord x, Evas_Coord y, int xposret, int yposret, Elm_Xdnd_Action action EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -237,7 +218,7 @@ _gl_dropcb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it, Elm_Se
|
||||||
if (ev->len <= 0)
|
if (ev->len <= 0)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
char *dd = _strndup(ev->data, ev->len);
|
char *dd = eina_strndup(ev->data, ev->len);
|
||||||
if (!dd) return EINA_FALSE;
|
if (!dd) return EINA_FALSE;
|
||||||
char *p = dd;
|
char *p = dd;
|
||||||
|
|
||||||
|
@ -292,7 +273,7 @@ _grid_dropcb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it, Elm_
|
||||||
if (ev->len <= 0)
|
if (ev->len <= 0)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
char *dd = _strndup(ev->data, ev->len);
|
char *dd = eina_strndup(ev->data, ev->len);
|
||||||
if (!dd) return EINA_FALSE;
|
if (!dd) return EINA_FALSE;
|
||||||
char *p = dd;
|
char *p = dd;
|
||||||
char *s = _drag_data_extract(&p);
|
char *s = _drag_data_extract(&p);
|
||||||
|
@ -1000,7 +981,7 @@ static Eina_Bool _drop_box_button_new_cb(void *data, Evas_Object *obj, Elm_Selec
|
||||||
if (ev->len <= 0)
|
if (ev->len <= 0)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
char *dd = _strndup(ev->data, ev->len);
|
char *dd = eina_strndup(ev->data, ev->len);
|
||||||
if (!dd) return EINA_FALSE;
|
if (!dd) return EINA_FALSE;
|
||||||
char *p = dd;
|
char *p = dd;
|
||||||
char *s = _drag_data_extract(&p);
|
char *s = _drag_data_extract(&p);
|
||||||
|
@ -1034,7 +1015,7 @@ static Eina_Bool _drop_but_icon_change_cb(void *data, Evas_Object *obj, Elm_Sele
|
||||||
if (ev->len <= 0)
|
if (ev->len <= 0)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
char *dd = _strndup(ev->data, ev->len);
|
char *dd = eina_strndup(ev->data, ev->len);
|
||||||
if (!dd) return EINA_FALSE;
|
if (!dd) return EINA_FALSE;
|
||||||
char *p = dd;
|
char *p = dd;
|
||||||
char *s = _drag_data_extract(&p);
|
char *s = _drag_data_extract(&p);
|
||||||
|
@ -1062,7 +1043,7 @@ static Eina_Bool _drop_bg_change_cb(void *data EINA_UNUSED, Evas_Object *obj, El
|
||||||
if (ev->len <= 0)
|
if (ev->len <= 0)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
char *dd = _strndup(ev->data, ev->len);
|
char *dd = eina_strndup(ev->data, ev->len);
|
||||||
if (!dd) return EINA_FALSE;
|
if (!dd) return EINA_FALSE;
|
||||||
char *p = dd;
|
char *p = dd;
|
||||||
char *s = _drag_data_extract(&p);
|
char *s = _drag_data_extract(&p);
|
||||||
|
|
|
@ -95,7 +95,7 @@ _generate_ref(const Eolian_State *state, const char *refn, Eina_Strbuf *wbuf)
|
||||||
}
|
}
|
||||||
if (cl)
|
if (cl)
|
||||||
{
|
{
|
||||||
char *meth = strndup(mname + 1, sfx - mname - 1);
|
char *meth = eina_strndup(mname + 1, sfx - mname - 1);
|
||||||
fn = eolian_class_function_by_name_get(cl, meth, ftype);
|
fn = eolian_class_function_by_name_get(cl, meth, ftype);
|
||||||
if (ftype == EOLIAN_UNRESOLVED)
|
if (ftype == EOLIAN_UNRESOLVED)
|
||||||
ftype = eolian_function_type_get(fn);
|
ftype = eolian_function_type_get(fn);
|
||||||
|
|
|
@ -112,7 +112,7 @@ ecore_cocoa_clipboard_get(int *size,
|
||||||
NSString *str = [items objectAtIndex: 0];
|
NSString *str = [items objectAtIndex: 0];
|
||||||
data = (void *)[str UTF8String];
|
data = (void *)[str UTF8String];
|
||||||
len = [str lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
|
len = [str lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
|
||||||
data = strndup((const char *)data, len);
|
data = eina_strndup((const char *)data, len);
|
||||||
|
|
||||||
if (EINA_UNLIKELY(!data))
|
if (EINA_UNLIKELY(!data))
|
||||||
{
|
{
|
||||||
|
|
|
@ -246,7 +246,7 @@ static inline char *
|
||||||
eina_slice_strdup(const Eina_Slice slice)
|
eina_slice_strdup(const Eina_Slice slice)
|
||||||
{
|
{
|
||||||
if (slice.len != 0)
|
if (slice.len != 0)
|
||||||
return strndup((const char *)slice.mem, slice.len);
|
return eina_strndup((const char *)slice.mem, slice.len);
|
||||||
return strdup("");
|
return strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ static inline char *
|
||||||
eina_rw_slice_strdup(const Eina_Rw_Slice rw_slice)
|
eina_rw_slice_strdup(const Eina_Rw_Slice rw_slice)
|
||||||
{
|
{
|
||||||
if (rw_slice.len != 0)
|
if (rw_slice.len != 0)
|
||||||
return strndup((const char *)rw_slice.mem, rw_slice.len);
|
return eina_strndup((const char *)rw_slice.mem, rw_slice.len);
|
||||||
return strdup("");
|
return strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "eina_str.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Eina_Slice_Group Memory Slices
|
* @addtogroup Eina_Slice_Group Memory Slices
|
||||||
*
|
*
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "eina_types.h"
|
#include "eina_types.h"
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ elm_code_line_indent_startswith_keyword(Elm_Code_Line *line)
|
||||||
unsigned int textlen;
|
unsigned int textlen;
|
||||||
|
|
||||||
text = (char *)elm_code_line_text_get(line, &textlen);
|
text = (char *)elm_code_line_text_get(line, &textlen);
|
||||||
text = strndup(text, textlen);
|
text = eina_strndup(text, textlen);
|
||||||
|
|
||||||
ret = regcomp(®ex, "^\\s*("
|
ret = regcomp(®ex, "^\\s*("
|
||||||
"((if|else\\s*if|while|for|switch)\\s*\\(.*\\)\\s*\\{?)|"
|
"((if|else\\s*if|while|for|switch)\\s*\\(.*\\)\\s*\\{?)|"
|
||||||
|
|
|
@ -68,9 +68,9 @@ EAPI void elm_code_line_split_at(Elm_Code_Line *line, unsigned int position)
|
||||||
char *content;
|
char *content;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
|
|
||||||
content = (char *) elm_code_line_text_get(line, &length);
|
content = (char *) elm_code_line_text_get(line, &length);
|
||||||
if (!content) return;
|
if (!content) return;
|
||||||
content = strndup(content, length);
|
content = eina_strndup(content, length);
|
||||||
if (!content) return;
|
if (!content) return;
|
||||||
elm_code_file_line_insert(line->file, line->number + 1, "", 0, NULL);
|
elm_code_file_line_insert(line->file, line->number + 1, "", 0, NULL);
|
||||||
newline = elm_code_file_line_get(line->file, line->number + 1);
|
newline = elm_code_file_line_get(line->file, line->number + 1);
|
||||||
|
|
|
@ -104,7 +104,7 @@ elm_code_line_text_substr(Elm_Code_Line *line, unsigned int position, int length
|
||||||
length = line->length - position;
|
length = line->length - position;
|
||||||
|
|
||||||
content = elm_code_line_text_get(line, NULL);
|
content = elm_code_line_text_get(line, NULL);
|
||||||
return strndup(content + position, length);
|
return eina_strndup(content + position, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1439,7 +1439,7 @@ _elm_code_widget_change_create(unsigned int start_col, unsigned int start_line,
|
||||||
info->end_col = end_col;
|
info->end_col = end_col;
|
||||||
info->end_line = end_line;
|
info->end_line = end_line;
|
||||||
|
|
||||||
info->content = strndup(text, length);
|
info->content = eina_strndup(text, length);
|
||||||
info->length = length;
|
info->length = length;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
|
@ -1523,7 +1523,7 @@ _elm_code_widget_newline(Elm_Code_Widget *widget)
|
||||||
line = elm_code_file_line_get(code->file, row);
|
line = elm_code_file_line_get(code->file, row);
|
||||||
}
|
}
|
||||||
oldtext = (char *) elm_code_line_text_get(line, &oldlen);
|
oldtext = (char *) elm_code_line_text_get(line, &oldlen);
|
||||||
oldtext = strndup(oldtext, oldlen);
|
oldtext = eina_strndup(oldtext, oldlen);
|
||||||
|
|
||||||
position = elm_code_widget_line_text_position_for_column_get(widget, line, col);
|
position = elm_code_widget_line_text_position_for_column_get(widget, line, col);
|
||||||
elm_code_line_split_at(line, position);
|
elm_code_line_split_at(line, position);
|
||||||
|
|
|
@ -33,7 +33,7 @@ _elm_code_widget_undo_info_copy(Elm_Code_Widget_Change_Info *info)
|
||||||
copy = calloc(1, sizeof(*info));
|
copy = calloc(1, sizeof(*info));
|
||||||
if (!copy) return NULL;
|
if (!copy) return NULL;
|
||||||
memcpy(copy, info, sizeof(*info));
|
memcpy(copy, info, sizeof(*info));
|
||||||
copy->content = strndup(info->content, info->length);
|
copy->content = eina_strndup(info->content, info->length);
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ _dict_hyphen_load(const char *lang)
|
||||||
ERR("Couldn't load hyphen dictionary: %s\n", dic_off - 5);
|
ERR("Couldn't load hyphen dictionary: %s\n", dic_off - 5);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_dicts_hyphen[_hyphens_num].lang = strndup(dic_off - 5, 5);
|
_dicts_hyphen[_hyphens_num].lang = eina_strndup(dic_off - 5, 5);
|
||||||
_dicts_hyphen[_hyphens_num++].dict = dict;
|
_dicts_hyphen[_hyphens_num++].dict = dict;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,24 +11,10 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bit related functions
|
* string related functions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
|
||||||
strndup(const char *str, size_t n)
|
|
||||||
{
|
|
||||||
size_t slen = strnlen(str, n);
|
|
||||||
char *ret;
|
|
||||||
|
|
||||||
ret = malloc (slen + 1);
|
|
||||||
if (!ret) return NULL;
|
|
||||||
|
|
||||||
if (slen > 0) memcpy(ret, str, slen);
|
|
||||||
ret[slen] = '\0';
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *strcasestr(const char *haystack, const char *needle)
|
char *strcasestr(const char *haystack, const char *needle)
|
||||||
{
|
{
|
||||||
size_t length_needle;
|
size_t length_needle;
|
||||||
|
|
|
@ -15,27 +15,9 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bit related functions
|
* string related functions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/**
|
|
||||||
* @brief Duplicate a string
|
|
||||||
*
|
|
||||||
* @param str String to be duplicated
|
|
||||||
* @param n size of new duplicated string
|
|
||||||
* @return The strndup() function returns a pointer to the duplicated string, or NULL if insufficient memory was available.
|
|
||||||
*
|
|
||||||
* This function returns a pointer to a new string which is a duplicate of the string str,
|
|
||||||
* but only copies at most n bytes. If str is longer than n, only n bytes are copied,
|
|
||||||
* and a terminating null byte ('\0') is added.
|
|
||||||
*
|
|
||||||
* Conformity: BSD
|
|
||||||
*
|
|
||||||
* Supported OS: Windows XP.
|
|
||||||
*
|
|
||||||
* @since 1.13
|
|
||||||
*/
|
|
||||||
EAPI char *strndup(const char *str, size_t n);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Locate a substring into a string, ignoring case.
|
* @brief Locate a substring into a string, ignoring case.
|
||||||
|
|
Loading…
Reference in New Issue