cleaning up remnants of bad rebase merges and modernizing some sections
[dana/openbox.git] / obrender / render.c
index 20002e3..fe9a2a8 100644 (file)
@@ -170,6 +170,8 @@ Pixmap RrPaintPixmap(RrAppearance *a, gint w, gint h)
             }
             force_transfer = 1;
         break;
+        case RR_TEXTURE_NUM_TYPES:
+            g_assert_not_reached();
         }
     }
 
@@ -200,7 +202,7 @@ RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex)
 {
   RrAppearance *out;
 
-  out = g_new0(RrAppearance, 1);
+  out = g_slice_new0(RrAppearance);
   out->inst = inst;
   out->textures = numtex;
   out->surface.bevel_light_adjust = 128;
@@ -229,10 +231,12 @@ void RrAppearanceClearTextures(RrAppearance *a)
     memset(a->texture, 0, a->textures * sizeof(RrTexture));
 }
 
+/* deep copy of orig, means reset ref to 1 on copy
+ * and copy each thing memwise. */
 RrAppearance *RrAppearanceCopy(RrAppearance *orig)
 {
     RrSurface *spo, *spc;
-    RrAppearance *copy = g_new(RrAppearance, 1);
+    RrAppearance *copy = g_slice_new(RrAppearance);
 
     copy->inst = orig->inst;
 
@@ -314,6 +318,7 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig)
     return copy;
 }
 
+/* now decrements ref counter, and frees only if ref <= 0 */
 void RrAppearanceFree(RrAppearance *a)
 {
     if (a) {
@@ -333,7 +338,7 @@ void RrAppearanceFree(RrAppearance *a)
         RrColorFree(p->split_secondary);
         g_free(p->pixel_data);
         p->pixel_data = NULL;
-        g_free(a);
+        g_slice_free(RrAppearance, a);
     }
 }
 
@@ -377,6 +382,8 @@ void RrMargins (RrAppearance *a, gint *l, gint *t, gint *r, gint *b)
             case RR_BEVEL_2:
                 *l = *t = *r = *b = 2;
                 break;
+            case RR_BEVEL_NUM_TYPES:
+                g_assert_not_reached();
             }
         } else if (a->surface.border) {
             *l = *t = *r = *b = 1;
@@ -414,7 +421,7 @@ gint RrMinWidth(RrAppearance *a)
                                     a->texture[i].data.text.flow,
                                     a->texture[i].data.text.maxwidth);
             w = MAX(w, m->width);
-            g_free(m);
+            g_slice_free(RrSize, m);
             break;
         case RR_TEXTURE_RGBA:
             w += MAX(w, a->texture[i].data.rgba.width);
@@ -426,6 +433,8 @@ gint RrMinWidth(RrAppearance *a)
             w = MAX(w, MAX(a->texture[i].data.lineart.x1 - l - r,
                            a->texture[i].data.lineart.x2 - l - r));
             break;
+        case RR_TEXTURE_NUM_TYPES:
+            g_assert_not_reached();
         }
     }
 
@@ -463,7 +472,7 @@ gint RrMinHeight(RrAppearance *a)
                      a->texture[i].data.text.flow,
                      a->texture[i].data.text.maxwidth);
                 h += MAX(h, m->height);
-                g_free(m);
+                g_slice_free(RrSize, m);
             }
             else
                 h += MAX(h,
@@ -481,6 +490,8 @@ gint RrMinHeight(RrAppearance *a)
             h = MAX(h, MAX(a->texture[i].data.lineart.y1 - t - b,
                            a->texture[i].data.lineart.y2 - t - b));
             break;
+        case RR_TEXTURE_NUM_TYPES:
+            g_assert_not_reached();
         }
     }