many optimizations and bugfixes in the new intersector code
[swftools.git] / lib / gfxpoly / xrow.c
index 123e00c..48fe7ad 100644 (file)
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+#include <stdio.h>
 #include "../mem.h"
 #include "xrow.h"
 
@@ -11,6 +13,9 @@ xrow_t* xrow_new()
 
 void xrow_add(xrow_t*r, int32_t x)
 {
+    if(r->num && r->lastx==x)
+        return;
+    r->lastx = x;
     if(r->num >= r->size) {
         r->size *= 2;
         r->x = rfx_realloc(r->x, sizeof(r->x[0])*r->size);
@@ -22,7 +27,7 @@ int compare_int32(const void*_i1,const void*_i2)
 {
     int32_t*i1 = (int32_t*)_i1;
     int32_t*i2 = (int32_t*)_i2;
-    return i1-i2;
+    return *i1-*i2;
 }
 
 void xrow_sort(xrow_t*r)
@@ -46,6 +51,18 @@ void xrow_reset(xrow_t*r)
     r->num = 0;
 }
 
+void xrow_dump(xrow_t*xrow)
+{
+    fprintf(stderr, "x: ");
+    int t;
+    for(t=0;t<xrow->num;t++) {
+        if(t)
+            fprintf(stderr, ", ");
+        fprintf(stderr, "%d", xrow->x[t]);
+    }
+    fprintf(stderr, "\n");
+}
+
 void xrow_destroy(xrow_t*r)
 {
     if(r->x) {