summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-05-12 18:52:24 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-05-12 19:34:07 +0900
commitee7ad21b3bd2eb131a07abbcadd7cd249c175d1d (patch)
tree8524b7989ff14d8ba7bd5c96060500f839ab4249
parent634d309d8592eb85a3b0616f3462c89fd9350a86 (diff)
test_dnd: Fix build for windows
There is no strndup (with our compilation flags).
-rw-r--r--src/bin/test_dnd.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/bin/test_dnd.c b/src/bin/test_dnd.c
index 9b5c0fb96..d799a04e6 100644
--- a/src/bin/test_dnd.c
+++ b/src/bin/test_dnd.c
@@ -203,6 +203,21 @@ _grid_item_getcb(Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *xposret, int
203 return item; 203 return item;
204} 204}
205 205
206static inline char *
207_strndup(const char *str, size_t len)
208{
209 size_t slen = strlen(str);
210 char *ret;
211
212 if (slen > len) slen = len;
213 ret = malloc (slen + 1);
214 if (!ret) return NULL;
215
216 if (slen > 0) memcpy(ret, str, slen);
217 ret[slen] = '\0';
218 return ret;
219}
220
206static Eina_Bool 221static Eina_Bool
207_gl_dropcb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it, Elm_Selection_Data *ev, int xposret EINA_UNUSED, int yposret) 222_gl_dropcb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it, Elm_Selection_Data *ev, int xposret EINA_UNUSED, int yposret)
208{ /* This function is called when data is dropped on the genlist */ 223{ /* This function is called when data is dropped on the genlist */
@@ -212,7 +227,7 @@ _gl_dropcb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it, Elm_Se
212 if (ev->len <= 0) 227 if (ev->len <= 0)
213 return EINA_FALSE; 228 return EINA_FALSE;
214 229
215 char *dd = strndup(ev->data, ev->len); 230 char *dd = _strndup(ev->data, ev->len);
216 if (!dd) return EINA_FALSE; 231 if (!dd) return EINA_FALSE;
217 char *p = dd; 232 char *p = dd;
218 233
@@ -267,7 +282,7 @@ _grid_dropcb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it, Elm_
267 if (ev->len <= 0) 282 if (ev->len <= 0)
268 return EINA_FALSE; 283 return EINA_FALSE;
269 284
270 char *dd = strndup(ev->data, ev->len); 285 char *dd = _strndup(ev->data, ev->len);
271 if (!dd) return EINA_FALSE; 286 if (!dd) return EINA_FALSE;
272 char *p = dd; 287 char *p = dd;
273 char *s = _drag_data_extract(&p); 288 char *s = _drag_data_extract(&p);
@@ -962,7 +977,7 @@ static Eina_Bool _drop_box_button_new_cb(void *data, Evas_Object *obj, Elm_Selec
962 if (ev->len <= 0) 977 if (ev->len <= 0)
963 return EINA_FALSE; 978 return EINA_FALSE;
964 979
965 char *dd = strndup(ev->data, ev->len); 980 char *dd = _strndup(ev->data, ev->len);
966 if (!dd) return EINA_FALSE; 981 if (!dd) return EINA_FALSE;
967 char *p = dd; 982 char *p = dd;
968 char *s = _drag_data_extract(&p); 983 char *s = _drag_data_extract(&p);
@@ -996,7 +1011,7 @@ static Eina_Bool _drop_but_icon_change_cb(void *data, Evas_Object *obj, Elm_Sele
996 if (ev->len <= 0) 1011 if (ev->len <= 0)
997 return EINA_FALSE; 1012 return EINA_FALSE;
998 1013
999 char *dd = strndup(ev->data, ev->len); 1014 char *dd = _strndup(ev->data, ev->len);
1000 if (!dd) return EINA_FALSE; 1015 if (!dd) return EINA_FALSE;
1001 char *p = dd; 1016 char *p = dd;
1002 char *s = _drag_data_extract(&p); 1017 char *s = _drag_data_extract(&p);
@@ -1024,7 +1039,7 @@ static Eina_Bool _drop_bg_change_cb(void *data EINA_UNUSED, Evas_Object *obj, El
1024 if (ev->len <= 0) 1039 if (ev->len <= 0)
1025 return EINA_FALSE; 1040 return EINA_FALSE;
1026 1041
1027 char *dd = strndup(ev->data, ev->len); 1042 char *dd = _strndup(ev->data, ev->len);
1028 if (!dd) return EINA_FALSE; 1043 if (!dd) return EINA_FALSE;
1029 char *p = dd; 1044 char *p = dd;
1030 char *s = _drag_data_extract(&p); 1045 char *s = _drag_data_extract(&p);