editor/parser: fix memory leaks detected by valgrind.
This commit is contained in:
parent
755da93bff
commit
cab3e34fa4
|
@ -18,7 +18,6 @@ typedef struct syntax_color_thread_data_s
|
||||||
{
|
{
|
||||||
Ecore_Thread *thread;
|
Ecore_Thread *thread;
|
||||||
edit_data *ed;
|
edit_data *ed;
|
||||||
char *text;
|
|
||||||
const char *translated;
|
const char *translated;
|
||||||
} syntax_color_td;
|
} syntax_color_td;
|
||||||
|
|
||||||
|
@ -302,8 +301,19 @@ static void
|
||||||
syntax_color_thread_cb(void *data, Ecore_Thread *thread)
|
syntax_color_thread_cb(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
syntax_color_td *td = data;
|
syntax_color_td *td = data;
|
||||||
|
ecore_thread_main_loop_begin();
|
||||||
|
if (!td->ed)
|
||||||
|
{
|
||||||
|
ecore_thread_main_loop_end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Evas_Object *tb = elm_entry_textblock_get(td->ed->en_edit);
|
||||||
|
const char *text = (char *) evas_object_textblock_text_markup_get(tb);
|
||||||
|
ecore_thread_main_loop_end();
|
||||||
|
|
||||||
char *utf8 = (char *) color_cancel(thread, syntax_color_data_get(td->ed->sh),
|
char *utf8 = (char *) color_cancel(thread, syntax_color_data_get(td->ed->sh),
|
||||||
td->text, strlen(td->text), -1, -1, NULL,
|
text, strlen(text), -1, -1, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (!utf8) return;
|
if (!utf8) return;
|
||||||
td->translated = color_apply(thread, syntax_color_data_get(td->ed->sh), utf8,
|
td->translated = color_apply(thread, syntax_color_data_get(td->ed->sh), utf8,
|
||||||
|
@ -894,7 +904,11 @@ syntax_color_full_update(edit_data *ed, Eina_Bool thread)
|
||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
{
|
{
|
||||||
if (ed->sctd) ecore_thread_cancel(ed->sctd->thread);
|
if (ed->sctd)
|
||||||
|
{
|
||||||
|
ecore_thread_cancel(ed->sctd->thread);
|
||||||
|
ed->sctd->ed = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ed->sctd = calloc(1, sizeof(syntax_color_td));
|
ed->sctd = calloc(1, sizeof(syntax_color_td));
|
||||||
if (!ed->sctd)
|
if (!ed->sctd)
|
||||||
|
@ -903,8 +917,6 @@ syntax_color_full_update(edit_data *ed, Eina_Bool thread)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ed->sctd->ed = ed;
|
ed->sctd->ed = ed;
|
||||||
Evas_Object *tb = elm_entry_textblock_get(ed->en_edit);
|
|
||||||
ed->sctd->text = (char *) evas_object_textblock_text_markup_get(tb);
|
|
||||||
ed->sctd->thread =
|
ed->sctd->thread =
|
||||||
ecore_thread_run(syntax_color_thread_cb,
|
ecore_thread_run(syntax_color_thread_cb,
|
||||||
syntax_color_thread_end_cb,
|
syntax_color_thread_end_cb,
|
||||||
|
|
|
@ -124,7 +124,7 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
p += QUOT_UTF8_LEN;
|
p += QUOT_UTF8_LEN;
|
||||||
p = strstr(p, QUOT_UTF8);
|
p = strstr(p, QUOT_UTF8);
|
||||||
if (!p) goto end;
|
if (!p) return;
|
||||||
p += QUOT_UTF8_LEN;
|
p += QUOT_UTF8_LEN;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
if (!strncmp(p, "#if", 3))
|
if (!strncmp(p, "#if", 3))
|
||||||
{
|
{
|
||||||
p = strstr(p, "#endif");
|
p = strstr(p, "#endif");
|
||||||
if (!p) goto end;
|
if (!p) return;
|
||||||
p += 6; //strlen(#endif)
|
p += 6; //strlen(#endif)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
while (p <= end)
|
while (p <= end)
|
||||||
{
|
{
|
||||||
char *eol = strstr(p, "\n");
|
char *eol = strstr(p, "\n");
|
||||||
if (!eol) goto end;
|
if (!eol) return;
|
||||||
|
|
||||||
char *slash = strstr(p, "\\");
|
char *slash = strstr(p, "\\");
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
inside_parts = EINA_TRUE;
|
inside_parts = EINA_TRUE;
|
||||||
p = strstr(p, "{");
|
p = strstr(p, "{");
|
||||||
if (!p) goto end;
|
if (!p) return;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,11 +221,11 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
p += PART_LEN[part_idx];
|
p += PART_LEN[part_idx];
|
||||||
char *name_begin = strstr(p, QUOT_UTF8);
|
char *name_begin = strstr(p, QUOT_UTF8);
|
||||||
if (!name_begin) goto end;
|
if (!name_begin) return;
|
||||||
name_begin += QUOT_UTF8_LEN;
|
name_begin += QUOT_UTF8_LEN;
|
||||||
p = name_begin;
|
p = name_begin;
|
||||||
char *name_end = strstr(p, QUOT_UTF8);
|
char *name_end = strstr(p, QUOT_UTF8);
|
||||||
if (!name_end) goto end;
|
if (!name_end) return;
|
||||||
part_name = name_begin;
|
part_name = name_begin;
|
||||||
part_name_len = name_end - name_begin;
|
part_name_len = name_end - name_begin;
|
||||||
p = name_end + QUOT_UTF8_LEN;
|
p = name_end + QUOT_UTF8_LEN;
|
||||||
|
@ -253,11 +253,10 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
/* skip keyword */
|
/* skip keyword */
|
||||||
p += DESC_LEN[desc_idx];
|
p += DESC_LEN[desc_idx];
|
||||||
p = strstr(p, "{");
|
p = strstr(p, "{");
|
||||||
if (!p) goto end;
|
if (!p) return;
|
||||||
/*Limit size of text for processing*/
|
/*Limit size of text for processing*/
|
||||||
char *end_brace = strstr(p, "}");
|
char *end_brace = strstr(p, "}");
|
||||||
if (!end_brace)
|
if (!end_brace) return;
|
||||||
goto end;
|
|
||||||
|
|
||||||
/* proccessing for "description" keyword with "state"
|
/* proccessing for "description" keyword with "state"
|
||||||
attribute */
|
attribute */
|
||||||
|
@ -281,7 +280,7 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
if (!name_begin)
|
if (!name_begin)
|
||||||
continue;
|
continue;
|
||||||
char *end_range = strstr(p, ";");
|
char *end_range = strstr(p, ";");
|
||||||
if (!end_range) goto end;
|
if (!end_range) return;
|
||||||
|
|
||||||
/* if string placed outside desc block*/
|
/* if string placed outside desc block*/
|
||||||
if ((name_begin > end_brace) || (name_begin > end_range) ||
|
if ((name_begin > end_brace) || (name_begin > end_range) ||
|
||||||
|
@ -302,7 +301,7 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
name_begin += QUOT_UTF8_LEN;
|
name_begin += QUOT_UTF8_LEN;
|
||||||
p = name_begin;
|
p = name_begin;
|
||||||
char *name_end = strstr(p, QUOT_UTF8);
|
char *name_end = strstr(p, QUOT_UTF8);
|
||||||
if (!name_end) goto end;
|
if (!name_end) return;
|
||||||
desc_name = name_begin;
|
desc_name = name_begin;
|
||||||
desc_name_len = name_end - name_begin;
|
desc_name_len = name_end - name_begin;
|
||||||
p = name_end + QUOT_UTF8_LEN;
|
p = name_end + QUOT_UTF8_LEN;
|
||||||
|
@ -337,11 +336,11 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
p += GROUP_LEN;
|
p += GROUP_LEN;
|
||||||
char *name_begin = strstr(p, QUOT_UTF8);
|
char *name_begin = strstr(p, QUOT_UTF8);
|
||||||
if (!name_begin) goto end;
|
if (!name_begin) return;
|
||||||
name_begin += QUOT_UTF8_LEN;
|
name_begin += QUOT_UTF8_LEN;
|
||||||
p = name_begin;
|
p = name_begin;
|
||||||
char *name_end = strstr(p, QUOT_UTF8);
|
char *name_end = strstr(p, QUOT_UTF8);
|
||||||
if (!name_end) goto end;
|
if (!name_end) return;
|
||||||
|
|
||||||
group_name = name_begin;
|
group_name = name_begin;
|
||||||
group_name_len = name_end - name_begin;
|
group_name_len = name_end - name_begin;
|
||||||
|
@ -363,10 +362,6 @@ cur_context_thread_blocking(void *data, Ecore_Thread *thread)
|
||||||
td->group_name = group_name;
|
td->group_name = group_name;
|
||||||
td->state_name = desc_name;
|
td->state_name = desc_name;
|
||||||
td->state_value = value_convert;
|
td->state_value = value_convert;
|
||||||
|
|
||||||
end:
|
|
||||||
free(utf8);
|
|
||||||
td->utf8 = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Stringshare *
|
Eina_Stringshare *
|
||||||
|
@ -492,6 +487,7 @@ cur_context_thread_cancel(void *data, Ecore_Thread *thread EINA_UNUSED)
|
||||||
eina_stringshare_del(td->state_name);
|
eina_stringshare_del(td->state_name);
|
||||||
eina_stringshare_del(td->part_name);
|
eina_stringshare_del(td->part_name);
|
||||||
eina_stringshare_del(td->group_name);
|
eina_stringshare_del(td->group_name);
|
||||||
|
free(td->utf8);
|
||||||
free(td);
|
free(td);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue