summaryrefslogtreecommitdiff
path: root/source/tools/murun.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-11-11 16:05:30 +0000
committerRobin Watts <robin.watts@artifex.com>2016-11-14 16:09:39 +0000
commit37f95f87bdfb2e0b01d649afae5fffe60bf99d3a (patch)
treeda3491c62d6af86c1a5bc4e523e8f9ebe19793d1 /source/tools/murun.c
parentc0e1dfdab1a13def046e94d771f8a821ba2a10d9 (diff)
downloadmupdf-37f95f87bdfb2e0b01d649afae5fffe60bf99d3a.tar.xz
Make fz_buffer structure private to fitz.
Move the definition of the structure contents into new fitz-imp.h file. Make all code outside of fitz access the buffer through the defined API. Add a convenience API for people that want to get buffers as null terminated C strings.
Diffstat (limited to 'source/tools/murun.c')
-rw-r--r--source/tools/murun.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c
index b1f95d57..7d26c49c 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -688,14 +688,16 @@ static int ffi_buffer_has(js_State *J, void *buf_, const char *key)
{
fz_buffer *buf = buf_;
int idx;
+ unsigned char *data;
+ size_t len = fz_buffer_storage(js_getcontext(J), buf, &data);
if (is_number(key, &idx)) {
- if (idx < 0 || (size_t)idx >= buf->len)
+ if (idx < 0 || (size_t)idx >= len)
js_rangeerror(J, "index out of bounds");
- js_pushnumber(J, buf->data[idx]);
+ js_pushnumber(J, data[idx]);
return 1;
}
if (!strcmp(key, "length")) {
- js_pushnumber(J, buf->len);
+ js_pushnumber(J, len);
return 1;
}
return 0;
@@ -705,10 +707,12 @@ static int ffi_buffer_put(js_State *J, void *buf_, const char *key)
{
fz_buffer *buf = buf_;
int idx;
+ unsigned char *data;
+ size_t len = fz_buffer_storage(js_getcontext(J), buf, &data);
if (is_number(key, &idx)) {
- if (idx < 0 || (size_t)idx >= buf->len)
+ if (idx < 0 || (size_t)idx >= len)
js_rangeerror(J, "index out of bounds");
- buf->data[idx] = js_tonumber(J, -1);
+ data[idx] = js_tonumber(J, -1);
return 1;
}
if (!strcmp(key, "length"))