OSSP CVS Repository

ossp - Difference in ossp-pkg/sio/al_test.c versions 1.13 and 1.14
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/sio/al_test.c 1.13 -> 1.14

--- al_test.c    2002/10/18 15:53:17     1.13
+++ al_test.c    2002/10/22 15:33:16     1.14
@@ -36,6 +36,11 @@
 
 #include "al.h"
 
+/* get unique pointers */
+static char label, label2;
+#define LABEL  ((al_label_t)&label)
+#define LABEL2 ((al_label_t)&label2)
+
 #define S(s) s, strlen(s)
 
 static const char *fill(char *p, int n)
@@ -65,12 +70,13 @@
     size_t len, pre, post;
 
     len = al_chunk_len(alc);
-    pre  = 20; if (pre > len) pre = len;
-    post = 20; if (post > len-pre) post = len-pre;
+    pre  = 16; if (pre > len) pre = len;
+    post = 16; if (post > len-pre) post = len-pre;
 
-    printf("C: %08lx + %-6d = ",
+    printf("C: %08lx + %-6d [%08lx] = ",
         (long)al_chunk_ptr(alc, 0),
-        al_chunk_len(alc));
+        al_chunk_len(alc),
+        (long)al_chunk_label(alc));
     fputs(fill(al_chunk_ptr(alc,0),pre), stdout);
     if (post > 0) {
         fputs(" .. ", stdout);
@@ -83,7 +89,7 @@
 
 #define DUMP(tag,al) do {\
 printf("+DUMP(%s)\n",tag);\
-al_traverse_cb(al, 0, al_bytes(al), AL_FORWARD, printchunk, NULL);\
+al_traverse_cb(al, 0, al_bytes(al), AL_FORWARD, LABEL, printchunk, NULL);\
 printf("-DUMP(%s)\n\n",tag);\
 } while (0)
 
@@ -92,11 +98,13 @@
     char *buf;
     size_t n, len;
 
+    return;
+
     n = al_bytes(al);
     buf = (char *)malloc(n);
     if (buf == NULL) abort();
 
-    al_flatten(al, 0, n, buf, &len);
+    al_flatten(al, 0, n, LABEL, buf, &len);
 
     printf("%s = %d of %d\n",tag,len,n);
     fwrite(">>", 2, 1, stdout);
@@ -116,7 +124,7 @@
     total = 0;
 
     al_txalloc(al, &tx);
-    al_traverse(al, 0, -1, AL_FORWARD, tx);
+    al_traverse(al, 0, -1, AL_FORWARD, NULL, tx);
     while (al_traverse_next(al, tx, &cur) == AL_OK)
         total += al_chunk_len(cur);
     al_traverse_end(al, tx, 1);
@@ -145,15 +153,15 @@
     al_create(&al2);
     al_create(&al3);
 
-    al_append_bytes(al, S("Hello world\n"));
-    al_attach_buffer(al, S(baf), reclaim, NULL);
+    al_append_bytes(al, S("Hello world\n"), LABEL);
+    al_attach_buffer(al, S(baf), LABEL, reclaim, NULL);
 
     for (i=0; i<500; ++i)
-        al_append_bytes(al, S("Huhu world\n"));
+        al_append_bytes(al, S("Huhu world\n"), LABEL);
 
-    al_append_bytes(al2, S("Hello world\n"));
+    al_append_bytes(al2, S("Hello world\n"), LABEL);
 
-    al_append_bytes(al3, S("HUHU WORLD\n"));
+    al_append_bytes(al3, S("HUHU WORLD\n"), LABEL2);
 
     DUMP("DATA",al);
     DUMP("BUFFER",al2);
@@ -167,7 +175,7 @@
     checklen("REPLACEMENT",al3);
 
     al_create(&al4);
-    rc = al_copy(al, al_bytes(al)-42, 38, al4);
+    rc = al_copy(al, al_bytes(al)-42, 38, LABEL, al4);
     printf("copy result: %d (%s)\n\n",rc,al_error(rc));
 
     DUMP("SPLICED",al);

CVSTrac 2.0.1