On Wed, Jan 23, 2013 at 12:34 PM, Guillaume Friloux <guillaume.fril...@asp64.com> wrote: > 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.
it's because you push in the array to be freed. I meant the previous way, if it had a warning, because it shouldn't. Basically this is being an useless strdup + 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! >> > Using the EINA_VALUE_BLOB_OPERATIONS_MALLOC or defining my own will lead to > double free. as said in the other email, it's incorrect to flush more than once. That should be fixed, then you can use (should use) the blob operations. -- Gustavo Sverzut Barbieri http://profusion.mobi embedded systems -------------------------------------- MSN: barbi...@gmail.com Skype: gsbarbieri Mobile: +55 (19) 9225-2202 ------------------------------------------------------------------------------ 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