This commit is contained in:
anon 2023-08-04 16:26:24 +02:00
commit ff3ae9ce59

View File

@ -100,7 +100,27 @@ rtos(void * data,
){
(void) colname;
char *const *const r = (char**)data;
char ** r = (char**)data;
size_t data_len = 0;
for(int i = 0; i < argc; i++)
{
if(argv[i])
{
data_len += strlen(argv[i]);
}
else
{
/* strlen("NULL") == 4 */
data_len += 4;
}
/* strlen("|") * 2 == 2 */
data_len += 2;
}
++data_len;
*r = (char *)calloc(data_len, sizeof(char));
for(int i = 0; i < argc; i++){
strcat(*r, "|");
if(argv[i]){
@ -120,9 +140,10 @@ DECL char *
dump()
{
char* errmsg;
/* TODO: allow for reallocing in rtos, start with a smaller value */
char* r = (char*)calloc(sizeof(char), 10000);
char* r = NULL;
DBERR(sqlite3_exec(connection, dump_stmt, rtos, &r, &errmsg));
return r;
}
@ -130,9 +151,10 @@ DECL char *
raw(char const * const sql)
{
char* errmsg;
/* TODO: allow for reallocing in rtos, start with a smaller value */
char *r = (char*)calloc(sizeof(char), 10000);
char *r = NULL;
sqlite3_exec(connection, sql, rtos, &r, &errmsg);
if (errmsg){
free(r);
r = errmsg;