summary refs log tree commit diff
path: root/transform.e
diff options
context:
space:
mode:
Diffstat (limited to 'transform.e')
-rw-r--r--transform.e20
1 files changed, 15 insertions, 5 deletions
diff --git a/transform.e b/transform.e
index 61cc4e0..f32448b 100644
--- a/transform.e
+++ b/transform.e
@@ -2708,10 +2708,18 @@ allocate-transformation-state s" transformation-state" variable
 ~ (length to write, base address --)
 : hex-sys-write-replacement
   { over } {
-    ~   The output metadata is an array of structs in the format: referenced
-    ~ data pointer; referenced data length; string pointer. It ends with a
-    ~ value of 0 where the referenced data pointer would be.
-    transformation-state transformation-state-output-metadata @
+    ~   The output metadata is a header structure followed by an array of
+    ~ entry structures, as follows:
+    ~
+    ~ (header start)
+    ~           0x00 - 0x07                     Output buffer length
+    ~ (entry start)
+    ~     ... + 0x00 - ... + 0x07               Data pointer
+    ~     ... + 0x08 - ... + 0x0f               Referenced data length
+    ~     ... + 0x10 - ... + 0x17               String pointer
+    ~ (entry fields repeat at successive offsets)
+    ~     ... + 0x00 - ... + 0x07 (end)         Zero, used as a delimiter
+    transformation-state transformation-state-output-metadata @ 8 +
     ~ (length remaining, current output address, metadata scan pointer)
     { dup @ dup { dup 2 pick >= drop } if
             ~ dup { dup 2 pick >= } if
@@ -2947,9 +2955,10 @@ allocate-transformation-state s" transformation-state" variable
 ~
 ~ (size -- pointer)
 : hex-allocate-replacement
-  allocate
+  dup allocate swap
 
   transformation-state transformation-state-output-metadata @
+  swap pack64
   ~ (result pointer, metadata output point)
 
   over pack64
@@ -3259,6 +3268,7 @@ allocate-transformation-state s" transformation-state" variable
   ~ hex-sys-write-replacement for more notes on its format.
   transformation-state transformation-state-output-metadata @
   0 pack64
+  0 pack64
   drop
 
   ~   It's important that the stack has nothing of ours on it that persists