Add clang-tidy target and fix problems
This commit is contained in:
parent
fca35ade9e
commit
f97b149376
25 changed files with 199 additions and 115 deletions
src
|
@ -1,3 +1,4 @@
|
|||
#include <bsd/string.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
@ -192,6 +193,10 @@ database_helper_get_ids(sqlite3_stmt *stmt)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(result)
|
||||
{
|
||||
free(result);
|
||||
}
|
||||
LOGGER_ERR("error selecting ids from database: %s\n", sqlite3_errstr(s));
|
||||
sqlite3_finalize(stmt);
|
||||
return NULL;
|
||||
|
@ -218,8 +223,14 @@ database_helper_get_string(sqlite3_stmt *stmt)
|
|||
if (s == SQLITE_ROW)
|
||||
{
|
||||
const char *found_string = (const char *)sqlite3_column_text(stmt, 0);
|
||||
result = (char*)malloc(sizeof(char) * (strlen(found_string) + 1));
|
||||
strcpy(result, found_string);
|
||||
size_t found_string_len = sqlite3_column_bytes(stmt, 0);
|
||||
|
||||
if(result)
|
||||
{
|
||||
free(result);
|
||||
}
|
||||
result = (char*)malloc(sizeof(char) * (found_string_len + 1));
|
||||
strlcpy(result, found_string, found_string_len + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -229,6 +240,10 @@ database_helper_get_string(sqlite3_stmt *stmt)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(result)
|
||||
{
|
||||
free(result);
|
||||
}
|
||||
LOGGER_ERR("error selecting string from database: %s\n", sqlite3_errstr(s));
|
||||
sqlite3_finalize(stmt);
|
||||
return NULL;
|
||||
|
@ -256,12 +271,12 @@ database_helper_get_strings(sqlite3_stmt *stmt)
|
|||
if (s == SQLITE_ROW)
|
||||
{
|
||||
const char *new_string = (const char *)sqlite3_column_text(stmt, 0);
|
||||
int new_string_len = strlen(new_string);
|
||||
size_t new_string_len = sqlite3_column_bytes(stmt, 0);
|
||||
row++;
|
||||
|
||||
result = (char**)realloc(result, sizeof(char*) * (row + 1));
|
||||
result[row - 1] = malloc(sizeof(char) * (new_string_len + 1));
|
||||
strcpy(result[row - 1], new_string);
|
||||
strlcpy(result[row - 1], new_string, new_string_len + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue