fts5CreateTokenizer pUserData destruction in case of failure

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

fts5CreateTokenizer pUserData destruction in case of failure

Stephen F. Booth
I have been working on a custom FTS5 tokenizer using SQLite 3.21.0.  I
noticed that in fts5CreateTokenizer() if the call to sqlite3_malloc() fails
SQLITE_NOMEM is returned, however xDestroy (if present) is not called.  A
similar situation is handled differently in sqlite3_bind_pointer(); in that
function, xDestructor is called on failure.  In case of a failure in
fts5CreateTokenizer() is it the caller's responsibility to invoke
xDestroy() or should this be handled by SQLite?

Stephen
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: fts5CreateTokenizer pUserData destruction in case of failure

Dan Kennedy-4
On 11/25/2017 02:57 AM, Stephen F. Booth wrote:
> I have been working on a custom FTS5 tokenizer using SQLite 3.21.0.  I
> noticed that in fts5CreateTokenizer() if the call to sqlite3_malloc() fails
> SQLITE_NOMEM is returned, however xDestroy (if present) is not called.  A
> similar situation is handled differently in sqlite3_bind_pointer(); in that
> function, xDestructor is called on failure.  In case of a failure in
> fts5CreateTokenizer() is it the caller's responsibility to invoke
> xDestroy() or should this be handled by SQLite?

Hi,

Ideally, it would have been handled by SQLite. But the API has been
released now, so I think we'll just document that xCreateFunction() and
xCreateTokenizer() do *not* invoke the xDestroy() if they fail. The
application has to clean up its own objects in this case. This happened
with sqlite3_create_collation_v2() as well.

Dan.


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users