Il 12/03/2014 07:31, Fam Zheng ha scritto:
+HBitmap *hbitmap_copy(const HBitmap *bitmap)
+{
+    int i;
+    HBitmap *hb = g_memdup(bitmap, sizeof(struct HBitmap));
+
+    for (i = HBITMAP_LEVELS; i-- > 0; ) {
+        hb->levels[i] = g_memdup(bitmap->levels[i],
+                                 bitmap->size * sizeof(unsigned long));
+    }
+
+    return hb;

Not quite... the bitmap->size is in bits, so you need to scale it down by

        size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);

before each memdup.

Paolo

Reply via email to