mirror of
https://github.com/janet-lang/janet
synced 2024-12-23 06:50:26 +00:00
added MARSH_EOS check
This commit is contained in:
parent
8e0d7f2539
commit
0eae75a5c2
@ -72,3 +72,15 @@
|
||||
(printf "properties:\n%p" (tarray/properties (A :array)))
|
||||
|
||||
(printf "row properties:\n%p" (tarray/properties (matrix/row A 1)))
|
||||
|
||||
|
||||
# test marshalling
|
||||
|
||||
(def a (tarray/new :float64 20))
|
||||
(set (a 0) math/pi)
|
||||
(set (a 1) 1234)
|
||||
|
||||
(def b (unmarshal (marshal a)))
|
||||
(printf "%p" (tarray/properties b))
|
||||
(print (b 0))
|
||||
(print (b 1))
|
||||
|
@ -919,10 +919,14 @@ void janet_unmarshal_size(JanetMarshalContext *ctx, size_t *i) {
|
||||
|
||||
|
||||
void janet_unmarshal_byte(JanetMarshalContext *ctx, uint8_t *b) {
|
||||
UnmarshalState *st = (UnmarshalState *)(ctx->u_state);
|
||||
MARSH_EOS(st, ctx->data);
|
||||
*b = *(ctx->data++);
|
||||
};
|
||||
|
||||
void janet_unmarshal_bytes(JanetMarshalContext *ctx, uint8_t *dest, int32_t len) {
|
||||
UnmarshalState *st = (UnmarshalState *)(ctx->u_state);
|
||||
MARSH_EOS(st, ctx->data+len-1);
|
||||
memcpy(dest, ctx->data, len);
|
||||
ctx->data += len;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user