diff --git a/src/bin/e.h b/src/bin/e.h index c45078a73..d8afcefa1 100644 --- a/src/bin/e.h +++ b/src/bin/e.h @@ -169,14 +169,6 @@ void *alloca (size_t); # define EINTERN # endif -#ifndef strdupa -# define strdupa(str) strcpy(alloca(strlen(str) + 1), str) -#endif - -#ifndef strndupa -# define strndupa(str, len) strncpy(alloca(len + 1), str, len) -#endif - typedef struct _E_Before_Idler E_Before_Idler; typedef struct _E_Rect E_Rect; diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c index 07c8a9170..e2bdc5b49 100644 --- a/src/bin/e_actions.c +++ b/src/bin/e_actions.c @@ -1926,8 +1926,10 @@ ACT_FN_GO(app, ) { Efreet_Desktop *desktop = NULL; char *p, *p2; + size_t plen; - p2 = strdupa(params); + plen = strlen(params); + p2 = memcpy(alloca(plen + 1), params, plen + 1); p = strchr(p2, ':'); if (p) { diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index 2049f1382..5d83b2621 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -1448,9 +1448,10 @@ E_API void e_fm2_parent_go(Evas_Object *obj) { char *p, *path; + char buf[PATH_MAX]; EFM_SMART_CHECK(); if (!sd->path) return; - path = strdupa(sd->path); + path = memcpy(buf, sd->path, strlen(sd->path + 1)); if ((p = strrchr(path, '/'))) *p = 0; if (*path) e_fm2_path_set(obj, sd->dev, path); @@ -5866,7 +5867,10 @@ _e_fm2_typebuf_match(Evas_Object *obj, int next) tb[tblen + 1] = '\0'; } else - tb = strdupa(sd->typebuf.buf); + { + size_t blen = strlen(sd->typebuf.buf); + tb = memcpy(alloca(blen + 1), sd->typebuf.buf, blen + 1); + } if (!next) { diff --git a/src/bin/e_fm/e_fm_ipc.c b/src/bin/e_fm/e_fm_ipc.c index b390d9c06..2e8245555 100644 --- a/src/bin/e_fm/e_fm_ipc.c +++ b/src/bin/e_fm/e_fm_ipc.c @@ -44,10 +44,6 @@ #include "e_fm_shared_codec.h" #define DEF_MOD_BACKOFF 0.2 -#ifndef strdupa -# define strdupa(str) strcpy(alloca(strlen(str) + 1), str) -#endif - typedef struct _E_Dir E_Dir; typedef struct _E_Fop E_Fop; typedef struct _E_Mod E_Mod; @@ -1160,8 +1156,8 @@ _e_fm_ipc_cb_fop_trash_idler(void *data) FILE *info = NULL; const char *filename; const char *escname = NULL; - char *dest, *trash_dir; - char buf[4096]; + char *dest; + char buf[4096], trash_dir[4096]; unsigned int i = 0; struct tm *lt; time_t t; @@ -1173,8 +1169,7 @@ _e_fm_ipc_cb_fop_trash_idler(void *data) if (!fop) return 0; /* Check that 'home trash' and subsequesnt dirs exists, create if not */ - snprintf(buf, sizeof(buf), "%s/Trash", efreet_data_home_get()); - trash_dir = strdupa(buf); + snprintf(trash_dir, sizeof(trash_dir), "%s/Trash", efreet_data_home_get()); snprintf(buf, sizeof(buf), "%s/files", trash_dir); if (!ecore_file_mkpath(buf)) return 0; snprintf(buf, sizeof(buf), "%s/info", trash_dir); diff --git a/src/bin/e_fm_op.c b/src/bin/e_fm_op.c index 4f7f5a7ce..f758269e4 100644 --- a/src/bin/e_fm_op.c +++ b/src/bin/e_fm_op.c @@ -44,10 +44,6 @@ void *alloca(size_t); #undef E_TYPEDEFS #include "e_fm_op.h" -#ifndef strdupa -# define strdupa(str) strcpy(alloca(strlen(str) + 1), str) -#endif - #define READBUFSIZE 65536 #define COPYBUFSIZE 16384 #define REMOVECHUNKSIZE 4096 @@ -1282,6 +1278,7 @@ static int _e_fm_op_copy_link(E_Fm_Op_Task *task) { char *lnk_path; + size_t lnk_len; lnk_path = ecore_file_readlink(task->src.name); if (!lnk_path) @@ -1289,6 +1286,8 @@ _e_fm_op_copy_link(E_Fm_Op_Task *task) _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot read link '%s'.", task->src.name); } + lnk_len = strlen(lnk_path); + E_FM_OP_DEBUG("Creating link from '%s' to '%s'\n", lnk_path, task->dst.name); _e_fm_op_update_progress_report_simple(0, lnk_path, task->dst.name); @@ -1305,14 +1304,14 @@ _e_fm_op_copy_link(E_Fm_Op_Task *task) } if (symlink(lnk_path, task->dst.name) == -1) { - buf = strdupa(lnk_path); + buf = memcpy(alloca(lnk_len + 1), lnk_path, lnk_len + 1); free(lnk_path); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", buf, task->dst.name); } } else { - buf = strdupa(lnk_path); + buf = memcpy(alloca(lnk_len + 1), lnk_path, lnk_len + 1); free(lnk_path); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", buf, task->dst.name); } diff --git a/src/bin/e_import_config_dialog.c b/src/bin/e_import_config_dialog.c index fe1cfdc6b..24fcebb5b 100644 --- a/src/bin/e_import_config_dialog.c +++ b/src/bin/e_import_config_dialog.c @@ -19,7 +19,7 @@ _import_edj_gen(E_Import_Config_Dialog *import) int fd, num = 1; int w = 0, h = 0; const char *file, *locale; - char buf[PATH_MAX], cmd[PATH_MAX], tmpn[PATH_MAX], ipart[PATH_MAX], enc[128]; + char buf[PATH_MAX], fbuf[PATH_MAX], cmd[PATH_MAX], tmpn[PATH_MAX], ipart[PATH_MAX], enc[128]; Eina_Tmpstr *path = NULL; char *imgdir = NULL, *fstrip; int cr, cg, cb, ca; @@ -82,12 +82,14 @@ _import_edj_gen(E_Import_Config_Dialog *import) if (import->external) { - fstrip = strdupa(e_util_filename_escape(import->file)); + const char *esc = e_util_filename_escape(import->file); + fstrip = memcpy(fbuf, esc, strlen(esc) + 1); snprintf(enc, sizeof(enc), "USER"); } else { - fstrip = strdupa(e_util_filename_escape(file)); + const char *esc = e_util_filename_escape(file); + fstrip = memcpy(fbuf, esc, strlen(esc) + 1); if (import->quality == 100) snprintf(enc, sizeof(enc), "COMP"); else diff --git a/src/bin/e_intl.c b/src/bin/e_intl.c index 75763ad6c..24f98f345 100644 --- a/src/bin/e_intl.c +++ b/src/bin/e_intl.c @@ -536,7 +536,8 @@ _e_intl_locale_alias_get(const char *language) { Eina_Hash *alias_hash; char *alias; - char *lower_language; + char llbuf[256]; + char *lower_language = llbuf; if ((!language) || (!strncmp(language, "POSIX", strlen("POSIX")))) return strdup("C"); @@ -545,9 +546,8 @@ _e_intl_locale_alias_get(const char *language) if (!alias_hash) /* No alias file available */ return strdup(language); - lower_language = strdupa(language); + strcpy(lower_language, language); eina_str_tolower(&lower_language); - alias = eina_hash_find(alias_hash, lower_language); if (alias) diff --git a/src/bin/e_theme.c b/src/bin/e_theme.c index d77640d9a..42820711f 100644 --- a/src/bin/e_theme.c +++ b/src/bin/e_theme.c @@ -41,8 +41,10 @@ e_theme_collection_items_find(const char *base EINA_UNUSED, const char *collname EINA_LIST_FREE(list, s) { char *trans, *p, *p2; + size_t slen; - trans = strdupa(s); + slen = strlen(s); + trans = memcpy(alloca(slen + 1), s, slen + 1); p = trans + len + 1; if (*p) { diff --git a/src/modules/conf_display/e_int_config_desks.c b/src/modules/conf_display/e_int_config_desks.c index 2b54c6be3..3d508a5c5 100644 --- a/src/modules/conf_display/e_int_config_desks.c +++ b/src/modules/conf_display/e_int_config_desks.c @@ -227,10 +227,11 @@ _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dia { char *p; const char *pp; + char buf[PATH_MAX]; pp = strchr(s, '/'); pp = pp ? pp + 1 : s; - p = strdupa(pp); + p = memcpy(buf, pp, strlen(pp) + 1); p[0] = toupper(p[0]); ob = e_widget_radio_add(evas, _(p), mode, rg); e_widget_list_object_append(o, ob, 1, 0, 0.5); diff --git a/src/modules/wizard/page_020.c b/src/modules/wizard/page_020.c index c3a1d94e5..c69a44670 100644 --- a/src/modules/wizard/page_020.c +++ b/src/modules/wizard/page_020.c @@ -7,13 +7,11 @@ static Evas_Object *textblock = NULL; static void _profile_change(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED) { - char buf[PATH_MAX]; - char *dir; + char buf[PATH_MAX], buf2[PATH_MAX]; Efreet_Desktop *desk = NULL; - e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s", profile); - dir = strdupa(buf); - snprintf(buf, sizeof(buf), "%s/profile.desktop", dir); + e_prefix_data_snprintf(buf2, sizeof(buf2), "data/config/%s", profile); + snprintf(buf, sizeof(buf), "%s/profile.desktop", buf2); desk = efreet_desktop_new(buf); if (desk) { @@ -62,8 +60,8 @@ wizard_page_show(E_Wizard_Page *pg) for (i = 0, l = profiles; l; l = l->next) { Efreet_Desktop *desk = NULL; - char buf[PATH_MAX], *prof; - const char *label, *dir; + char buf[PATH_MAX], buf2[PATH_MAX], *prof; + const char *label; Evas_Object *ic; prof = l->data; @@ -75,26 +73,25 @@ wizard_page_show(E_Wizard_Page *pg) continue; } } - e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s", prof); + e_prefix_data_snprintf(buf2, sizeof(buf2), "data/config/%s", prof); // if it's not a system profile - don't offer it - if (!ecore_file_is_dir(buf)) + if (!ecore_file_is_dir(buf2)) { free(prof); continue; } - dir = strdupa(buf); if (!strcmp(prof, "standard")) sel = i; - snprintf(buf, sizeof(buf), "%s/profile.desktop", dir); + snprintf(buf, sizeof(buf), "%s/profile.desktop", buf2); desk = efreet_desktop_new(buf); label = prof; if ((desk) && (desk->name)) label = desk->name; - snprintf(buf, sizeof(buf), "%s/icon.edj", dir); + snprintf(buf, sizeof(buf), "%s/icon.edj", buf2); if ((desk) && (desk->icon)) { if (eina_str_has_extension(desk->icon, "png")) - snprintf(buf, sizeof(buf), "%s/%s", dir, desk->icon); + snprintf(buf, sizeof(buf), "%s/%s", buf2, desk->icon); else - snprintf(buf, sizeof(buf), "%s/%s.png", dir, desk->icon); + snprintf(buf, sizeof(buf), "%s/%s.png", buf2, desk->icon); } else e_prefix_data_concat_static(buf, "data/images/enlightenment.png");