Drag mbtiles handling into C++

This commit is contained in:
Eric Fischer
2016-04-27 12:38:04 -07:00
parent d32d4bb35f
commit 94db232a89
+8 -5
View File
@@ -7,7 +7,10 @@
#include <sqlite3.h> #include <sqlite3.h>
#include "pool.h" #include "pool.h"
#include "tile.h" #include "tile.h"
#include "mbtiles.h"
extern "C" {
#include "mbtiles.h"
};
sqlite3 *mbtiles_open(char *dbname, char **argv, int forcetable) { sqlite3 *mbtiles_open(char *dbname, char **argv, int forcetable) {
sqlite3 *outdb; sqlite3 *outdb;
@@ -98,7 +101,7 @@ static void quote(char **buf, const char *s) {
} }
*out = '\0'; *out = '\0';
*buf = realloc(*buf, strlen(*buf) + strlen(tmp) + 1); *buf = (char *) realloc(*buf, strlen(*buf) + strlen(tmp) + 1);
if (*buf == NULL) { if (*buf == NULL) {
perror("realloc"); perror("realloc");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@@ -117,7 +120,7 @@ static void aprintf(char **buf, const char *format, ...) {
} }
va_end(ap); va_end(ap);
*buf = realloc(*buf, strlen(*buf) + strlen(tmp) + 1); *buf = (char *) realloc(*buf, strlen(*buf) + strlen(tmp) + 1);
if (*buf == NULL) { if (*buf == NULL) {
perror("Out of memory"); perror("Out of memory");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@@ -127,8 +130,8 @@ static void aprintf(char **buf, const char *format, ...) {
} }
static int pvcmp(const void *v1, const void *v2) { static int pvcmp(const void *v1, const void *v2) {
const struct pool_val *const *pv1 = v1; const struct pool_val *const *pv1 = (const struct pool_val *const *) v1;
const struct pool_val *const *pv2 = v2; const struct pool_val *const *pv2 = (const struct pool_val *const *) v2;
int n = strcmp((*pv1)->s, (*pv2)->s); int n = strcmp((*pv1)->s, (*pv2)->s);
if (n != 0) { if (n != 0) {