summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--upb/bytestream.c2
-rw-r--r--upb/bytestream.h7
-rw-r--r--upb/pb/decoder_x64.dasc6
-rw-r--r--upb/pb/textprinter.c4
-rw-r--r--upb/table.c8
-rw-r--r--upb/upb.h2
7 files changed, 19 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index ae30bf0..5320876 100644
--- a/Makefile
+++ b/Makefile
@@ -164,7 +164,7 @@ upb/pb/jit_debug_elf_file.o: upb/pb/jit_debug_elf_file.s
upb/pb/jit_debug_elf_file.h: upb/pb/jit_debug_elf_file.o
$(E) XXD $<
- $(Q) xxd -i upb/pb/jit_debug_elf_file.o > upb/pb/jit_debug_elf_file.h
+ $(Q) xxd -i < upb/pb/jit_debug_elf_file.o > upb/pb/jit_debug_elf_file.h
upb/pb/decoder_x64.h: upb/pb/jit_debug_elf_file.h
endif
diff --git a/upb/bytestream.c b/upb/bytestream.c
index 86095f9..41a84b0 100644
--- a/upb/bytestream.c
+++ b/upb/bytestream.c
@@ -63,7 +63,7 @@ static upb_stdio_buf *upb_stdio_findbuf(const upb_stdio *s, uint64_t ofs) {
}
static upb_stdio_buf *upb_stdio_rotatebufs(upb_stdio *s) {
- upb_stdio_buf *reuse[s->nbuf];
+ upb_stdio_buf **reuse = NULL; // XXX
uint32_t num_reused = 0, num_inuse = 0;
// Could sweep only a subset of bufs if this was a hotspot.
diff --git a/upb/bytestream.h b/upb/bytestream.h
index 6ec1ba6..cbaef48 100644
--- a/upb/bytestream.h
+++ b/upb/bytestream.h
@@ -215,9 +215,10 @@ INLINE int upb_bytesink_putc(upb_bytesink *sink, char ch) {
}
INLINE int upb_bytesink_putrepeated(upb_bytesink *sink, char ch, int len) {
- char buf[len];
- memset(buf, ch, len);
- return upb_bytesink_write(sink, buf, len);
+ for (int i = 0; i < len; i++)
+ if (upb_bytesink_write(sink, &ch, 1) < 0)
+ return -1;
+ return len;
}
INLINE uint64_t upb_bytesink_getoffset(upb_bytesink *sink) {
diff --git a/upb/pb/decoder_x64.dasc b/upb/pb/decoder_x64.dasc
index c56506e..72c4aa1 100644
--- a/upb/pb/decoder_x64.dasc
+++ b/upb/pb/decoder_x64.dasc
@@ -44,7 +44,9 @@
// for a few magic numbers and doing a dumb string replacement.
#ifndef __APPLE__
+const unsigned char upb_jit_debug_elf_file[] = {
#include "upb/pb/jit_debug_elf_file.h"
+};
typedef enum
{
@@ -73,9 +75,9 @@ void __attribute__((noinline)) __jit_debug_register_code() { __asm__ __volatile_
void upb_reg_jit_gdb(upb_decoder *d) {
// Create debug info.
- size_t elf_len = upb_pb_jit_debug_elf_file_o_len;
+ size_t elf_len = sizeof(upb_jit_debug_elf_file);
d->debug_info = malloc(elf_len);
- memcpy(d->debug_info, upb_pb_jit_debug_elf_file_o, elf_len);
+ memcpy(d->debug_info, upb_jit_debug_elf_file, elf_len);
uint64_t *p = (void*)d->debug_info;
for (; (void*)(p+1) <= (void*)d->debug_info + elf_len; ++p) {
if (*p == 0x12345678) { *p = (uintptr_t)d->jit_code; }
diff --git a/upb/pb/textprinter.c b/upb/pb/textprinter.c
index 434a482..4056b8f 100644
--- a/upb/pb/textprinter.c
+++ b/upb/pb/textprinter.c
@@ -41,7 +41,7 @@ static int upb_textprinter_putescaped(upb_textprinter *p, const upb_strref *strr
// TODO; we could read directly from a bytesrc's buffer instead.
// TODO; we could write strrefs to the sink when possible.
char dstbuf[4096], *dst = dstbuf, *dstend = dstbuf + sizeof(dstbuf);
- char buf[strref->len], *src = buf;
+ char *buf = malloc(strref->len), *src = buf;
char *end = src + strref->len;
upb_bytesrc_read(strref->bytesrc, strref->stream_offset, strref->len, buf);
@@ -81,8 +81,10 @@ static int upb_textprinter_putescaped(upb_textprinter *p, const upb_strref *strr
}
// Flush remaining data.
CHECK(upb_bytesink_write(p->sink, dst, dst - dstbuf));
+ free(buf);
return 0;
err:
+ free(buf);
return -1;
}
diff --git a/upb/table.c b/upb/table.c
index f0d8d3e..31c91b1 100644
--- a/upb/table.c
+++ b/upb/table.c
@@ -189,7 +189,7 @@ void upb_inttable_compact(upb_inttable *t) {
int lg2_array = 0;
while ((1UL << lg2_array) < largest_key) ++lg2_array;
++lg2_array; // Undo the first iteration.
- size_t array_size;
+ size_t array_size = 0;
int array_count = 0;
while (lg2_array > 0) {
array_size = (1 << --lg2_array);
@@ -306,10 +306,12 @@ void *upb_strtable_lookup(const upb_strtable *t, const char *key) {
void *upb_strtable_lookupl(const upb_strtable *t, const char *key, size_t len) {
// TODO: improve.
- char key2[len+1];
+ char *key2 = malloc(len+1);
memcpy(key2, key, len);
key2[len] = '\0';
- return upb_strtable_lookup(t, key2);
+ void *ret = upb_strtable_lookup(t, key2);
+ free(key2);
+ return ret;
}
static uint32_t empty_strbucket(upb_strtable *table) {
diff --git a/upb/upb.h b/upb/upb.h
index e2a7dc3..8c78d9a 100644
--- a/upb/upb.h
+++ b/upb/upb.h
@@ -115,7 +115,7 @@ typedef struct {
uint8_t size;
uint8_t native_wire_type;
uint8_t inmemory_type; // For example, INT32, SINT32, and SFIXED32 -> INT32
- char *ctype;
+ const char *ctype;
} upb_type_info;
// A static array of info about all of the field types, indexed by type number.
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback