[SR-Users] [PATCH] modules_k/db_sqlite: new sql backend
Alex Hermann
alex at speakup.nl
Mon Apr 4 16:07:45 CEST 2011
On Monday 04 April 2011, Timo Teräs wrote:
> Implements the kamailio database API for SQLite.
> +static str* str_dup(const char *_s)
> +{
> + str *s;
> + int len = strlen(_s);
> +
> + s = (str*) pkg_malloc(sizeof(str)+len+1);
> + s->len = len;
> + s->s = ((char*)s) + sizeof(str);
> + memcpy(s->s, _s, len);
> + s->s[len] = '\0';
> +
> + return s;
> +}
> +
> +static void str_assign(str* s, const char *_s, int len)
> +{
> + s->s = (char *) pkg_malloc(len + 1);
> + s->len = len;
> + memcpy(s->s, _s, len);
> + s->s[len] = 0;
> +}
You should really check the return value of all pkg_*alloc() function calls.
--
Alex Hermann
More information about the sr-users
mailing list