On 23/01/2013 15:02, Gustavo Sverzut Barbieri wrote:
On Wed, Jan 23, 2013 at 10:29 AM, Enlightenment SVN <no-re...@enlightenment.org> wrote:+ { + char *text; + text = strdup(sqlite3_column_text(res->e->backend.stmt, i)); + eina_value_setup(&inv, EINA_VALUE_TYPE_STRING); + eina_value_set(&inv, text); + eina_array_push(memory, text); + break;Are you sure? Did you run in valgrind? I think this is wrong, because:http://trac.enlightenment.org/e/browser/trunk/efl/src/lib/eina/eina_value.c#L2323 that is, it will duplicate the text inside inv. There is no need to do this strdup() or push it. And it will free the duplicated memory of inv when you call eina_value_flush().
Ran in valgrind, yes. no warnings, no leaks.
I know i should, i did hesitate, but as its very small, i allowed me to do so.- eina_value_setup(&inv, EINA_VALUE_TYPE_INT64); - eina_value_set(&inv, sqlite3_column_int64(res->e->backend.stmt, i)); + eina_value_setup(&inv, EINA_VALUE_TYPE_INT64); + eina_value_set(&inv, sqlite3_column_int64(res->e->backend.stmt, i)); break; case SQLITE_FLOAT: - eina_value_setup(&inv, EINA_VALUE_TYPE_DOUBLE); - eina_value_set(&inv, sqlite3_column_double(res->e->backend.stmt, i)); + eina_value_setup(&inv, EINA_VALUE_TYPE_DOUBLE); + eina_value_set(&inv, sqlite3_column_double(res->e->backend.stmt, i)); break;avoid mixing the whitespace cleanups with real patch.
Using the EINA_VALUE_BLOB_OPERATIONS_MALLOC or defining my own will lead to double free.default: { Eina_Value_Blob blob; + char *tmp; + int size; + size = sqlite3_column_bytes(res->e->backend.stmt, i); + tmp = malloc(size); + memcpy(tmp, sqlite3_column_blob(res->e->backend.stmt, i), size); + blob.ops = NULL; - blob.memory = sqlite3_column_blob(res->e->backend.stmt, i); - blob.size = sqlite3_column_bytes(res->e->backend.stmt, i); - + blob.memory = tmp; + blob.size = size; eina_value_setup(&inv, EINA_VALUE_TYPE_BLOB); - eina_value_set(&inv, &blob); + eina_value_set(&inv, blob); + eina_array_push(memory, tmp);here it is almost right: http://trac.enlightenment.org/e/browser/trunk/efl/src/lib/eina/eina_value.c#L3820 it need the blob.memory to be allocated (as you do), but eina_value_flush() will automatically clean the memory if you provide EINA_VALUE_BLOB_OPERATIONS_MALLOC as ops. Then do this and do not use this memory array at all. I know I should have looked into this, I'm glad you did the hard work to check why it failed (the blob part!), now it's just this minor details and we're gold :-) Thanks!
<<attachment: guillaume_friloux.vcf>>
------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d
_______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel