summaryrefslogtreecommitdiffstats
path: root/libdimension/interior.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-06-12 02:37:51 -0600
committerTavian Barnes <tavianator@gmail.com>2011-06-13 00:16:06 -0600
commit7acd8ea6673b7a90ed4041408ccf1b024b8a007a (patch)
treed52199dd7c58e0217bfd1a74e7601d739ad333f5 /libdimension/interior.c
parent066261810c2fca192677c5c1c01c91d6ecec65a0 (diff)
downloaddimension-7acd8ea6673b7a90ed4041408ccf1b024b8a007a.tar.xz
Vast libdimension API and internals improvements.
Couldn't really do these while I was trying to be POV-Ray compatible, 'cause they would've broken compatibility.
Diffstat (limited to 'libdimension/interior.c')
-rw-r--r--libdimension/interior.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libdimension/interior.c b/libdimension/interior.c
index 0594e06..47ba19f 100644
--- a/libdimension/interior.c
+++ b/libdimension/interior.c
@@ -33,7 +33,7 @@ dmnsn_new_interior(void)
dmnsn_interior *interior = dmnsn_malloc(sizeof(dmnsn_interior));
interior->ior = 1.0;
interior->free_fn = NULL;
- interior->refcount = 0;
+ interior->refcount = 1;
return interior;
}
@@ -41,10 +41,21 @@ dmnsn_new_interior(void)
void
dmnsn_delete_interior(dmnsn_interior *interior)
{
- if (interior && DMNSN_DECREF(interior)) {
+ if (DMNSN_DECREF(interior)) {
if (interior->free_fn) {
interior->free_fn(interior->ptr);
}
dmnsn_free(interior);
}
}
+
+/* Cascade a interior */
+void
+dmnsn_interior_cascade(dmnsn_interior *default_interior,
+ dmnsn_interior **interiorp)
+{
+ if (!*interiorp) {
+ *interiorp = default_interior;
+ DMNSN_INCREF(*interiorp);
+ }
+}