summaryrefslogtreecommitdiff
path: root/java-plan1/Unpacker.java
diff options
context:
space:
mode:
Diffstat (limited to 'java-plan1/Unpacker.java')
-rw-r--r--java-plan1/Unpacker.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/java-plan1/Unpacker.java b/java-plan1/Unpacker.java
index be86344..32945de 100644
--- a/java-plan1/Unpacker.java
+++ b/java-plan1/Unpacker.java
@@ -50,13 +50,26 @@ public class Unpacker {
return finished;
}
+ public void reset()
+ {
+ for(int i=0; i <= top; ++top) {
+ stack_ct[top] = 0;
+ stack_count[top] = 0;
+ stack_obj[top] = null;
+ stack_map_key[top] = null;
+ }
+ cs = CS_HEADER;
+ trail = 0;
+ top = -1;
+ finished = false;
+ }
@SuppressWarnings("unchecked")
public int execute(byte[] src, int off, int length) throws IOException
{
if(off >= length) { return off; }
- int limit = off + length;
+ int limit = length;
int i = off;
int count;
@@ -64,7 +77,7 @@ public class Unpacker {
_out: do {
_header_again: {
- //System.out.println("while i:"+i);
+ //System.out.println("while i:"+i+" limit:"+limit);
int b = src[i];
@@ -349,6 +362,7 @@ public class Unpacker {
((ArrayList)(stack_obj[top])).add(obj);
if(--stack_count[top] == 0) {
obj = stack_obj[top];
+ stack_obj[top] = null;
--top;
break _push;
}
@@ -363,6 +377,8 @@ public class Unpacker {
((HashMap)(stack_obj[top])).put(stack_map_key[top], obj);
if(--stack_count[top] == 0) {
obj = stack_obj[top];
+ stack_map_key[top] = null;
+ stack_obj[top] = null;
--top;
break _push;
}
@@ -379,7 +395,7 @@ public class Unpacker {
++i;
} while(i < limit); // _out
- return i - off;
+ return i;
}
}