aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Huang <jimmy.huang@intel.com>2017-03-24 15:12:10 -0700
committerGeoff Gustafson <geoff@linux.intel.com>2017-03-27 08:12:33 -0700
commit00a76112248652e2fdadeb1336c438d8f8b11050 (patch)
tree3fca072da4bdaab1e1137ac4c1288fc56c6317a7
parent157ab89975a6c6fe864192347b834e75104f52aa (diff)
[snapshot] Fixed bytecode array bug
Since we storing unint32_t instead of uint8_t, there's bug that we are creating an array that's 4 times the needed size with a bunch of 0s, this patch fixes this issue Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
-rw-r--r--src/main.c2
-rw-r--r--tools/snapshot.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index ce3c6d8..22365d2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -44,7 +44,7 @@
const uint32_t snapshot_bytecode[] = {
#include "zjs_snapshot_gen.h"
};
-const size_t snapshot_len = sizeof(snapshot_bytecode) / sizeof(uint32_t);
+const size_t snapshot_len = sizeof(snapshot_bytecode);
#else
const char script_jscode[] = {
#include "zjs_script_gen.h"
diff --git a/tools/snapshot.c b/tools/snapshot.c
index f692ead..6a962ae 100644
--- a/tools/snapshot.c
+++ b/tools/snapshot.c
@@ -12,7 +12,7 @@ static uint32_t snapshot_buf[SNAPSHOT_BUFFER_SIZE];
static void generate_snapshot(uint32_t *buf, int buf_size)
{
- for (int i = 0; i < buf_size; i++)
+ for (int i = 0; i < buf_size / sizeof(uint32_t); i++)
{
if (i > 0) {
printf(",");