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