aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-20 18:25:58 +1000
committerDavid Walter Seikel2014-05-20 18:25:58 +1000
commit315aaabbce6b2db52ff5796708b777b488fd848e (patch)
treeb58c92292cda35e4435b2448d61a654e30580c7d /src/libraries
parentClean up the server startup and connection a bit. (diff)
downloadSledjHamr-315aaabbce6b2db52ff5796708b777b488fd848e.zip
SledjHamr-315aaabbce6b2db52ff5796708b777b488fd848e.tar.gz
SledjHamr-315aaabbce6b2db52ff5796708b777b488fd848e.tar.bz2
SledjHamr-315aaabbce6b2db52ff5796708b777b488fd848e.tar.xz
The results of a session with valgrind.
I'm surprised that this highly experimental code, built with chewing gum and chicken wire, had so little problems, and most of those where leaks. The majority of problems reported are from external libraries.
Diffstat (limited to '')
-rw-r--r--src/libraries/Runnr.c22
-rw-r--r--src/libraries/SledjHamr.c3
-rw-r--r--src/libraries/winFang.c15
3 files changed, 25 insertions, 15 deletions
diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c
index b775e19..72bc523 100644
--- a/src/libraries/Runnr.c
+++ b/src/libraries/Runnr.c
@@ -151,6 +151,9 @@ static char *_push_name(lua_State *L, char *q, int *idx) // Stack usage [-0, +1
151 return q; 151 return q;
152} 152}
153 153
154/* It's the callers job to stash things safely before returning from the Lua to C function call.
155 * Coz things like strings might go away after the stack is freed.
156 */
154int pull_lua(lua_State *L, int i, char *params, ...) // Stack usage - 157int pull_lua(lua_State *L, int i, char *params, ...) // Stack usage -
155 // if i is a table 158 // if i is a table
156 // [-n, +n, e] 159 // [-n, +n, e]
@@ -210,16 +213,15 @@ int pull_lua(lua_State *L, int i, char *params, ...) // Stack usage -
210 if (lua_isstring(L, j)) // Stack usage [-0, +0, -] 213 if (lua_isstring(L, j)) // Stack usage [-0, +0, -]
211 { 214 {
212 char **v = va_arg(vl, char **); 215 char **v = va_arg(vl, char **);
213 size_t len; 216
214 char *temp = (char *) lua_tolstring(L, j, &len); // Stack usage [-0, +0, m] 217 // We could strdup the string, but that causes leaks.
215 218 // The problem is that the caller doesn't know if we allocated or not,
216 len++; // Cater for the null at the end. 219 // since the incoming pointer could already be pointing to a default value.
217 *v = malloc(len); 220 // Lua says the string is valid until it's popped off the stack,
218 if (*v) 221 // and this is used only in calls to C functions from Lua.
219 { 222 // So just document that it's the callers job to stash it safely if needed after returning.
220 memcpy(*v, temp, len); 223 *v = (char *) lua_tostring(L, j);
221 n++; 224 n++;
222 }
223 } 225 }
224 break; 226 break;
225 } 227 }
diff --git a/src/libraries/SledjHamr.c b/src/libraries/SledjHamr.c
index 7fcede7..5f26fde 100644
--- a/src/libraries/SledjHamr.c
+++ b/src/libraries/SledjHamr.c
@@ -47,6 +47,9 @@ static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev)
47 } 47 }
48 48
49 if (ev->server) ecore_con_server_del(ev->server); 49 if (ev->server) ecore_con_server_del(ev->server);
50 // TODO - Hmm, I think this is where this should be freed, but it causes a seggie in reachOut's while loop.
51 // Which is odd, so leave it commented for now and investigate later.
52// free(this);
50 53
51 return ECORE_CALLBACK_CANCEL; 54 return ECORE_CALLBACK_CANCEL;
52} 55}
diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c
index b6ceee9..bfd9327 100644
--- a/src/libraries/winFang.c
+++ b/src/libraries/winFang.c
@@ -369,28 +369,29 @@ void winFangCalcMinSize(winFang *win)
369 369
370void winFangDel(winFang *win) 370void winFangDel(winFang *win)
371{ 371{
372 winFang *wf; 372 winFang *wf, *wf2;
373 Widget *wid; 373 Widget *wid, *wid2;
374 374
375 if (!win) return; 375 if (!win) return;
376 376
377 if (win->bg) eo_unref(win->bg); 377 if (win->bg) eo_unref(win->bg);
378 if (win->grid) eo_unref(win->grid); 378 if (win->grid) eo_unref(win->grid);
379 if (win->layout) eo_unref(win->layout); 379 if (win->layout) eo_unref(win->layout);
380 EINA_CLIST_FOR_EACH_ENTRY(wf, &win->winFangs, winFang, node) 380 EINA_CLIST_FOR_EACH_ENTRY_SAFE(wf, wf2, &win->winFangs, winFang, node)
381 { 381 {
382 winFangDel(wf); 382 winFangDel(wf);
383 } 383 }
384 384
385 // Elm will delete our widgets, but if we are using eo, we need to unref them. 385 // Elm will delete our widgets, but if we are using eo, we need to unref them.
386 EINA_CLIST_FOR_EACH_ENTRY(wid, &win->widgets, Widget, node) 386 EINA_CLIST_FOR_EACH_ENTRY_SAFE(wid, wid2, &win->widgets, Widget, node)
387 { 387 {
388 if (wid->on_del) wid->on_del(wid, wid->obj, NULL); 388 if (wid->on_del) wid->on_del(wid, wid->obj, NULL);
389 widgetDel(wid); 389 widgetDel(wid);
390 eo_unref(wid->obj);
391 } 390 }
392 if (win->on_del) win->on_del(win, win->win, NULL); 391 if (win->on_del) win->on_del(win, win->win, NULL);
393 evas_object_del(win->win); 392 evas_object_del(win->win);
393 free(win->module);
394 free(win);
394} 395}
395 396
396 397
@@ -483,10 +484,14 @@ void widgetDel(Widget *wid)
483{ 484{
484 if (wid) 485 if (wid)
485 { 486 {
487 free(wid->action);
488 free(wid->label);
486 // TODO - This is to work around a bug in Elm entry, remove it when the bug is fixed. 489 // TODO - This is to work around a bug in Elm entry, remove it when the bug is fixed.
487 // The bug is that editable entry widgets cause the app to hang on exit. 490 // The bug is that editable entry widgets cause the app to hang on exit.
488 if (strcmp(WT_ENTRY, wid->type) == 0) 491 if (strcmp(WT_ENTRY, wid->type) == 0)
489 elm_entry_editable_set(wid->obj, EINA_FALSE); 492 elm_entry_editable_set(wid->obj, EINA_FALSE);
493 eo_unref(wid->obj);
494 free(wid);
490 } 495 }
491} 496}
492 497