static inline void zmalloc size_t void malloc assert memset return sta

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+static inline void *zmalloc(size_t x)
+{
+ void *z = malloc(x);
+ assert(z);
+ memset(z, 0, x);
+ return z;
+}
+
+static inline char *strndup_lite(const char *s, size_t n)
+{
+ char *dup = malloc(n+1);
+ assert(dup);
+ memcpy(dup, s, n);
+ *(dup+n) = '\0';
+ return dup;
+}
+
#define ENTER_MALLOC 0
-#define sqliteMalloc(x) sqlite3Malloc(x,1)
-#define sqliteMallocRaw(x) sqlite3MallocRaw(x,1)
-#define sqliteRealloc(x,y) sqlite3Realloc(x,y)
-#define sqliteStrDup(x) sqlite3StrDup(x)
-#define sqliteStrNDup(x,y) sqlite3StrNDup(x,y)
+#define sqliteMalloc(x) zmalloc(x)//sqlite3Malloc(x,1)
+#define sqliteMallocRaw(x) malloc(x)//sqlite3MallocRaw(x,1)
+#define sqliteRealloc(x,y) realloc(x, y)//sqlite3Realloc(x,y)
+#define sqliteStrDup(x) strdup(x)//sqlite3StrDup(x)
+#define sqliteStrNDup(x,y) strndup_lite(x,y) //sqlite3StrNDup(x,y)
#define sqliteReallocOrFree(x,y) sqlite3ReallocOrFree(x,y)
#endif
-#define sqliteFree(x) sqlite3FreeX(x)
+#define sqliteFree(x) if (x) { free((void *)x); x = NULL;} //sqlite3FreeX(x)
#define sqliteAllocSize(x) sqlite3AllocSize(x)