new function code_dup
authorkramm <kramm>
Tue, 23 Dec 2008 18:43:41 +0000 (18:43 +0000)
committerkramm <kramm>
Tue, 23 Dec 2008 18:43:41 +0000 (18:43 +0000)
lib/as3/code.c
lib/as3/code.h

index 2ca7082..62dd2a1 100644 (file)
@@ -1045,6 +1045,26 @@ code_t* code_append(code_t*code, code_t*toappend)
     return code_end(toappend);
 }
 
+code_t*code_dup(code_t*c)
+{
+    if(!c) return 0;
+
+    while(c->prev) c = c->prev;
+
+    code_t*last = 0;
+    while(c) {
+        NEW(code_t, n);
+        memcpy(n, c, sizeof(code_t));
+        n->prev = last;
+        if(last) {
+            last->next = n;
+        }
+        last = n;
+        c = c->next;
+    }
+    return last;
+}
+
 code_t*code_cutlast(code_t*c)
 {
     assert(!c->next);
index 6345fba..6e326a3 100644 (file)
@@ -77,6 +77,8 @@ struct _codelookup {
     int len;
 };
 
+code_t*code_dup(code_t*c); //shallow copy
+
 code_t*add_opcode(code_t*atag, U8 op);
 
 code_t*code_parse(TAG*tag, int len, abc_file_t*file, pool_t*pool, codelookup_t**codelookup);