Skip to content

Commit 6575b8c

Browse files
fix build without per-thd-malloc
Signed-off-by: Akshat Sikarwar <[email protected]>
1 parent c9b0e8d commit 6575b8c

File tree

3 files changed

+22
-35
lines changed

3 files changed

+22
-35
lines changed

Diff for: sqlite/src/comdb2build.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static char** genShardGetShardNames(char *tablename, uint32_t nshards) {
606606
}
607607
free(result);
608608
}
609-
return result;
609+
return NULL;
610610
}
611611

612612
static int comdb2SqlSchemaChange_int(OpFunc *f, int usedb)

Diff for: sqlite/src/comdb2vdbe.c

+21-32
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#include "vdbeInt.h"
33
#include "vdbe.h"
44

5-
6-
inline int initOpFunc(OpFunc* o, size_t len)
5+
static int initOpFunc(OpFunc* o, size_t len)
76
{
87
assert( o != NULL );
98

@@ -17,41 +16,31 @@ inline int initOpFunc(OpFunc* o, size_t len)
1716
return o->buf == NULL;
1817
}
1918

20-
inline int initOpFuncDefault(OpFunc* o)
19+
static int initOpFuncDefault(OpFunc* o)
2120
{
2221
return initOpFunc(o, DEFAULT_OPFUNC_BUFLEN);
2322
}
2423

25-
static inline int resize_buf(OpFunc* o, int size)
24+
static int resize_buf(OpFunc *o, int size)
2625
{
27-
char* old_buf = o->buf;
28-
int write_offset = o->writeNext - old_buf;
29-
int read_offset = o->readNext - old_buf;
30-
31-
int newsize = o->end - old_buf;
32-
33-
for (; newsize < size; newsize *= 2);
34-
35-
char *newbuf = realloc(old_buf, newsize);
36-
37-
if (!newbuf)
38-
return -1;
39-
40-
o->buf = newbuf;
41-
42-
if (o->buf != old_buf)
43-
{
44-
o->writeNext = o->buf + write_offset;
45-
o->readNext = o->buf + read_offset;
46-
}
47-
48-
o->end = o->buf + newsize;
49-
o->len = newsize;
50-
return 0;
26+
char *old_buf = o->buf;
27+
ptrdiff_t write_offset = o->writeNext - old_buf;
28+
ptrdiff_t read_offset = o->readNext - old_buf;
29+
ptrdiff_t newsize = o->end - old_buf;
30+
while (newsize < size) newsize *= 2;
31+
char *newbuf = realloc(old_buf, newsize);
32+
if (!newbuf) return -1;
33+
if (o->buf != newbuf) {
34+
o->writeNext = newbuf + write_offset;
35+
o->readNext = newbuf + read_offset;
36+
o->buf = newbuf;
37+
}
38+
o->end = o->buf + newsize;
39+
o->len = newsize;
40+
return 0;
5141
}
5242

53-
54-
inline void freeOpFunc(OpFunc* func)
43+
void freeOpFunc(OpFunc* func)
5544
{
5645
if (!func)
5746
return;
@@ -67,7 +56,7 @@ inline void freeOpFunc(OpFunc* func)
6756

6857
}
6958

70-
static inline void shallowFreeOpFuncSetup(OpFuncSetup* stp)
59+
static void shallowFreeOpFuncSetup(OpFuncSetup* stp)
7160
{
7261
free(stp);
7362
}
@@ -77,7 +66,7 @@ static const char* OPFUNC_NOROWS_COLNAMES[] = {0};
7766
static int OPFUNC_NOROWS_COLTYPES[] = {0};
7867
static size_t OPFUNC_NOROWS_BUFSIZE = 0;
7968

80-
static inline OpFuncSetup* getNoRowsSetup()
69+
static OpFuncSetup* getNoRowsSetup()
8170
{
8271
OpFuncSetup* stp = malloc(sizeof(OpFuncSetup));
8372

Diff for: sqlite/src/comdb2vdbe.h

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
typedef struct OpFuncSetup OpFuncSetup;
88

9-
int initOpFunc(OpFunc* o, size_t len);
10-
int initOpFuncDefault(OpFunc* o);
119
void freeOpFunc(OpFunc* o);
1210
int moreRecords(OpFunc* opf);
1311
char* nextString(OpFunc* opf, Mem* mem);

0 commit comments

Comments
 (0)