[vlc-devel] [PATCH] SQLite module

Srikanth Raju srikiraju at gmail.com
Wed Nov 25 12:31:55 CET 2009


Hi,

> > +struct sql_stmt_t

> > +{

> > +    sqlite3_stmt* p_sqlitestmt;

> > +};

> >

> > Using the SQLite pointer directly would be simpler.

>

> Maybe. But sql_stmt_t is used in vlc_sql.h. It wouldn't go well with other

> sql modules



I fail to see a problem here. I never said you should expose SQLite
> typedefs outside.


typedef sqlite3_stmt sql_stmt_t; doesn't work as it conflicts with the
typedef from vlc_sql.h
Should I do #define sql_stmt_t sqlite3_stmt, it makes a lot of warnings


> >> > +static char* VMSprintf( const char* psz_fmt, va_list args )
> >> > > +{
> >> > > +    char *psz = sqlite3_vmprintf( psz_fmt, args );
> >> > > +    char *ret = strdup( psz );
> >> > > +    sqlite3_free( psz );
> >> > > +    return ret;
> >> > > +}
> >> > >
> >> > > Do we really need this double copy/allocation?
> >> >
> >> > Yes. psz is allocated with sqlite3_malloc. Some "fastmem" builds can
> >> > use different allocation strategies, hence we cannot rely on free()
> >> > to free psz. Hence the copy.
> >>
> >> That's not the point. Why do you need strdup and free?
> >>
> > Is there a way to do this without strdup?
>
> What's wrong with using sqlite3_free() directly _after_ you are done?
>

API user doesn't know about sqlite3_free()


-- 
Regards,
Srikanth Raju
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20091125/05b54fed/attachment.html>


More information about the vlc-devel mailing list