aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_file
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-04-22 12:03:25 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-04-23 23:07:48 +0900
commite4d815dc48c660a336670ec3cc67e6becbdcacfc (patch)
tree7c9be7ba0a493b5fe40c6ea99167a0ecbe9a54f7 /src/lib/ecore_file
parentedje_edit: fix mempools in group/alias add (diff)
downloadefl-e4d815dc48c660a336670ec3cc67e6becbdcacfc.tar.gz
efreetd - reduce memory usage by using stringshare much more
lots of long paths for monitoring file paths for icons etc. are in memory for efreetd. this reduces that memory by sharing them much more. @optimization
Diffstat (limited to 'src/lib/ecore_file')
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_inotify.c13
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_poll.c13
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_win32.c20
-rw-r--r--src/lib/ecore_file/ecore_file_private.h2
4 files changed, 23 insertions, 25 deletions
diff --git a/src/lib/ecore_file/ecore_file_monitor_inotify.c b/src/lib/ecore_file/ecore_file_monitor_inotify.c
index f86b58d631..374d709265 100644
--- a/src/lib/ecore_file/ecore_file_monitor_inotify.c
+++ b/src/lib/ecore_file/ecore_file_monitor_inotify.c
@@ -107,7 +107,8 @@ ecore_file_monitor_backend_add(const char *path,
void *data)
{
Ecore_File_Monitor *em;
- int len;
+ char *path2;
+ size_t len;
if (_inotify_fd_pid == -1) return NULL;
@@ -123,10 +124,10 @@ ecore_file_monitor_backend_add(const char *path,
em->func = func;
em->data = data;
- em->path = strdup(path);
- len = strlen(em->path);
- if (em->path[len - 1] == '/' && strcmp(em->path, "/"))
- em->path[len - 1] = 0;
+ len = strlen(path);
+ path2 = alloca(len + 1);
+ if (path2[len - 1] == '/' && strcmp(path2, "/")) path2[len - 1] = 0;
+ em->path = eina_stringshare_add(path2);
_monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
@@ -149,7 +150,7 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
fd = ecore_main_fd_handler_fd_get(_fdh);
if (ECORE_FILE_MONITOR_INOTIFY(em)->wd)
inotify_rm_watch(fd, ECORE_FILE_MONITOR_INOTIFY(em)->wd);
- free(em->path);
+ eina_stringshare_del(em->path);
free(em);
}
diff --git a/src/lib/ecore_file/ecore_file_monitor_poll.c b/src/lib/ecore_file/ecore_file_monitor_poll.c
index 088787e3e9..16f84194ce 100644
--- a/src/lib/ecore_file/ecore_file_monitor_poll.c
+++ b/src/lib/ecore_file/ecore_file_monitor_poll.c
@@ -68,6 +68,7 @@ ecore_file_monitor_backend_add(const char *path,
void *data)
{
Ecore_File_Monitor *em;
+ char *path2;
size_t len;
if (!path) return NULL;
@@ -81,14 +82,14 @@ ecore_file_monitor_backend_add(const char *path,
else
ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN);
- em->path = strdup(path);
- len = strlen(em->path);
- if (em->path[len - 1] == '/' && strcmp(em->path, "/"))
- em->path[len - 1] = 0;
-
em->func = func;
em->data = data;
+ len = strlen(path);
+ path2 = alloca(len + 1);
+ if (path2[len - 1] == '/' && strcmp(path2, "/")) path2[len - 1] = 0;
+ em->path = eina_stringshare_add(path2);
+
ECORE_FILE_MONITOR_POLL(em)->mtime = ecore_file_mod_time(em->path);
_monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
@@ -160,7 +161,7 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
if (_monitors)
_monitors = ECORE_FILE_MONITOR(eina_inlist_remove(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
- free(em->path);
+ eina_stringshare_del(em->path);
free(em);
if (_timer)
diff --git a/src/lib/ecore_file/ecore_file_monitor_win32.c b/src/lib/ecore_file/ecore_file_monitor_win32.c
index f6186f6773..20f2ad02ad 100644
--- a/src/lib/ecore_file/ecore_file_monitor_win32.c
+++ b/src/lib/ecore_file/ecore_file_monitor_win32.c
@@ -243,6 +243,7 @@ ecore_file_monitor_backend_add(const char *path,
{
Ecore_File_Monitor_Win32 *m;
Ecore_File_Monitor *em;
+ char *path2;
size_t len;
if (!path || (*path == '\0')) return NULL;
@@ -256,22 +257,17 @@ ecore_file_monitor_backend_add(const char *path,
em->func = func;
em->data = data;
- em->path = strdup(path);
- if (!em->path)
- {
- free(em);
- return NULL;
- }
- len = strlen(em->path);
- if (em->path[len - 1] == '/' || em->path[len - 1] == '\\')
- em->path[len - 1] = '\0';
+ len = strlen(path);
+ path2 = alloca(len + 1);
+ if (path2[len - 1] == '/' || path2[len - 1] == '\\') path2[len - 1] = 0;
+ em->path = eina_stringshare_add(path2);
m = ECORE_FILE_MONITOR_WIN32(em);
m->file = _ecore_file_monitor_win32_data_new(em, 0);
if (!m->file)
{
- free(em->path);
+ eina_stringshare_del(em->path);
free(em);
return NULL;
}
@@ -280,7 +276,7 @@ ecore_file_monitor_backend_add(const char *path,
if (!m->dir)
{
_ecore_file_monitor_win32_data_free(m->file);
- free(em->path);
+ eina_stringshare_del(em->path);
free(em);
return NULL;
}
@@ -301,6 +297,6 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
m = ECORE_FILE_MONITOR_WIN32(em);
_ecore_file_monitor_win32_data_free(m->dir);
_ecore_file_monitor_win32_data_free(m->file);
- free(em->path);
+ eina_stringshare_del(em->path);
free(em);
}
diff --git a/src/lib/ecore_file/ecore_file_private.h b/src/lib/ecore_file/ecore_file_private.h
index 82f9767153..7c33ec8f34 100644
--- a/src/lib/ecore_file/ecore_file_private.h
+++ b/src/lib/ecore_file/ecore_file_private.h
@@ -76,7 +76,7 @@ struct _Ecore_File_Monitor
Ecore_File_Event event,
const char *path);
- char *path;
+ const char *path;
void *data;
Ecore_File *files;
};