summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/bvh.c8
-rw-r--r--libdimension/camera.c4
-rw-r--r--libdimension/canvas.c4
-rw-r--r--libdimension/cone.c6
-rw-r--r--libdimension/dictionary.c4
-rw-r--r--libdimension/dimension/malloc.h10
-rw-r--r--libdimension/finish.c10
-rw-r--r--libdimension/future.c2
-rw-r--r--libdimension/gradient.c4
-rw-r--r--libdimension/interior.c4
-rw-r--r--libdimension/lambertian.c4
-rw-r--r--libdimension/light.c4
-rw-r--r--libdimension/map.c4
-rw-r--r--libdimension/object.c4
-rw-r--r--libdimension/pattern.c4
-rw-r--r--libdimension/pigment.c4
-rw-r--r--libdimension/pigment_map.c5
-rw-r--r--libdimension/plane.c4
-rw-r--r--libdimension/png.c8
-rw-r--r--libdimension/point_light.c5
-rw-r--r--libdimension/ray_trace.c3
-rw-r--r--libdimension/reflection.c5
-rw-r--r--libdimension/scene.c4
-rw-r--r--libdimension/tests/display.c4
-rw-r--r--libdimension/tests/refcount.c4
-rw-r--r--libdimension/texture.c4
-rw-r--r--libdimension/threads.c4
-rw-r--r--libdimension/torus.c4
-rw-r--r--libdimension/triangle.c5
29 files changed, 70 insertions, 69 deletions
diff --git a/libdimension/bvh.c b/libdimension/bvh.c
index d27f84e..972401e 100644
--- a/libdimension/bvh.c
+++ b/libdimension/bvh.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2012-2013 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2012-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -131,7 +131,7 @@ dmnsn_flatten_bvh(dmnsn_bvh_node *root)
dmnsn_bvh *dmnsn_new_bvh(const dmnsn_array *objects, dmnsn_bvh_kind kind)
{
- dmnsn_bvh *bvh = dmnsn_malloc(sizeof(dmnsn_bvh));
+ dmnsn_bvh *bvh = DMNSN_MALLOC(dmnsn_bvh);
dmnsn_array *bounded = dmnsn_split_objects(objects);
bvh->unbounded = dmnsn_split_unbounded(bounded);
@@ -239,7 +239,7 @@ dmnsn_get_intersection_cache(const dmnsn_bvh *bvh)
= pthread_getspecific(bvh->intersection_cache);
if (!cache) {
- cache = dmnsn_malloc(sizeof(dmnsn_intersection_cache));
+ cache = DMNSN_MALLOC(dmnsn_intersection_cache);
cache->i = 0;
for (size_t i = 0; i < DMNSN_INTERSECTION_CACHE_SIZE; ++i) {
cache->objects[i] = NULL;
@@ -374,7 +374,7 @@ dmnsn_new_bvh_node(size_t max_children)
dmnsn_bvh_node *
dmnsn_new_bvh_leaf_node(dmnsn_object *object)
{
- dmnsn_bvh_node *node = dmnsn_malloc(sizeof(dmnsn_bvh_node));
+ dmnsn_bvh_node *node = DMNSN_MALLOC(dmnsn_bvh_node);
node->bounding_box = object->bounding_box;
node->object = object;
node->nchildren = 0;
diff --git a/libdimension/camera.c b/libdimension/camera.c
index 0a007ea..1c5a1fc 100644
--- a/libdimension/camera.c
+++ b/libdimension/camera.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -30,7 +30,7 @@
dmnsn_camera *
dmnsn_new_camera(void)
{
- dmnsn_camera *camera = dmnsn_malloc(sizeof(dmnsn_camera));
+ dmnsn_camera *camera = DMNSN_MALLOC(dmnsn_camera);
camera->free_fn = NULL;
camera->trans = dmnsn_identity_matrix();
DMNSN_REFCOUNT_INIT(camera);
diff --git a/libdimension/canvas.c b/libdimension/canvas.c
index 9bf2056..0242671 100644
--- a/libdimension/canvas.c
+++ b/libdimension/canvas.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -30,7 +30,7 @@
dmnsn_canvas *
dmnsn_new_canvas(size_t width, size_t height)
{
- dmnsn_canvas *canvas = dmnsn_malloc(sizeof(dmnsn_canvas));
+ dmnsn_canvas *canvas = DMNSN_MALLOC(dmnsn_canvas);
canvas->width = width;
canvas->height = height;
canvas->optimizers = dmnsn_new_array(sizeof(dmnsn_canvas_optimizer));
diff --git a/libdimension/cone.c b/libdimension/cone.c
index f1536e2..a2d2d55 100644
--- a/libdimension/cone.c
+++ b/libdimension/cone.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2013 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -124,7 +124,7 @@ dmnsn_new_cone_cap(double r)
cap->bounding_box.min = dmnsn_new_vector(-r, 0.0, -r);
cap->bounding_box.max = dmnsn_new_vector(+r, 0.0, +r);
- double *payload = dmnsn_malloc(sizeof(double));
+ double *payload = DMNSN_MALLOC(double);
*payload = r;
cap->ptr = payload;
cap->free_fn = dmnsn_free;
@@ -143,7 +143,7 @@ dmnsn_new_cone(double r1, double r2, bool open)
cone->bounding_box.min = dmnsn_new_vector(-rmax, -1.0, -rmax);
cone->bounding_box.max = dmnsn_new_vector(rmax, 1.0, rmax);
- dmnsn_cone_payload *payload = dmnsn_malloc(sizeof(dmnsn_cone_payload));
+ dmnsn_cone_payload *payload = DMNSN_MALLOC(dmnsn_cone_payload);
payload->r1 = r1;
payload->r2 = r2;
cone->ptr = payload;
diff --git a/libdimension/dictionary.c b/libdimension/dictionary.c
index ea6bbdc..3264a3c 100644
--- a/libdimension/dictionary.c
+++ b/libdimension/dictionary.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -35,7 +35,7 @@ struct dmnsn_dictionary {
dmnsn_dictionary *
dmnsn_new_dictionary(size_t obj_size)
{
- dmnsn_dictionary *dict = dmnsn_malloc(sizeof(dmnsn_dictionary));
+ dmnsn_dictionary *dict = DMNSN_MALLOC(dmnsn_dictionary);
dict->obj_size = obj_size;
dict->prefix = dmnsn_strdup("");
dict->value = NULL;
diff --git a/libdimension/dimension/malloc.h b/libdimension/dimension/malloc.h
index 4151800..742e3a2 100644
--- a/libdimension/dimension/malloc.h
+++ b/libdimension/dimension/malloc.h
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -36,6 +36,14 @@
void *dmnsn_malloc(size_t size);
/**
+ * Allocate some memory. Always use dmnsn_free() to free this memory, never
+ * free().
+ * @param[in] type The type of the memory block to allocate.
+ * @return The allocated memory area.
+ */
+#define DMNSN_MALLOC(type) ((type *)dmnsn_malloc(sizeof(type)))
+
+/**
* Expand or shrink an allocation created by dmnsn_malloc().
* @param[in] ptr The block to resize.
* @param[in] size The new size.
diff --git a/libdimension/finish.c b/libdimension/finish.c
index 620487e..6178db3 100644
--- a/libdimension/finish.c
+++ b/libdimension/finish.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -28,7 +28,7 @@
dmnsn_ambient *
dmnsn_new_ambient(dmnsn_color ambient_light)
{
- dmnsn_ambient *ambient = dmnsn_malloc(sizeof(dmnsn_ambient));
+ dmnsn_ambient *ambient = DMNSN_MALLOC(dmnsn_ambient);
ambient->ambient = ambient_light;
DMNSN_REFCOUNT_INIT(ambient);
return ambient;
@@ -45,7 +45,7 @@ dmnsn_delete_ambient(dmnsn_ambient *ambient)
dmnsn_diffuse *
dmnsn_new_diffuse(void)
{
- dmnsn_diffuse *diffuse = dmnsn_malloc(sizeof(dmnsn_diffuse));
+ dmnsn_diffuse *diffuse = DMNSN_MALLOC(dmnsn_diffuse);
diffuse->free_fn = NULL;
diffuse->ptr = NULL;
DMNSN_REFCOUNT_INIT(diffuse);
@@ -66,7 +66,7 @@ dmnsn_delete_diffuse(dmnsn_diffuse *diffuse)
dmnsn_specular *
dmnsn_new_specular(void)
{
- dmnsn_specular *specular = dmnsn_malloc(sizeof(dmnsn_specular));
+ dmnsn_specular *specular = DMNSN_MALLOC(dmnsn_specular);
specular->free_fn = NULL;
specular->ptr = NULL;
DMNSN_REFCOUNT_INIT(specular);
@@ -87,7 +87,7 @@ dmnsn_delete_specular(dmnsn_specular *specular)
dmnsn_reflection *
dmnsn_new_reflection(void)
{
- dmnsn_reflection *reflection = dmnsn_malloc(sizeof(dmnsn_reflection));
+ dmnsn_reflection *reflection = DMNSN_MALLOC(dmnsn_reflection);
reflection->free_fn = NULL;
reflection->ptr = NULL;
DMNSN_REFCOUNT_INIT(reflection);
diff --git a/libdimension/future.c b/libdimension/future.c
index f62c01d..0b16234 100644
--- a/libdimension/future.c
+++ b/libdimension/future.c
@@ -37,7 +37,7 @@
dmnsn_future *
dmnsn_new_future(void)
{
- dmnsn_future *future = dmnsn_malloc(sizeof(dmnsn_future));
+ dmnsn_future *future = DMNSN_MALLOC(dmnsn_future);
future->progress = 0;
future->total = 1;
diff --git a/libdimension/gradient.c b/libdimension/gradient.c
index 53689d2..38b460b 100644
--- a/libdimension/gradient.c
+++ b/libdimension/gradient.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -41,7 +41,7 @@ dmnsn_new_gradient_pattern(dmnsn_vector orientation)
{
dmnsn_pattern *gradient = dmnsn_new_pattern();
- dmnsn_vector *payload = dmnsn_malloc(sizeof(dmnsn_vector));
+ dmnsn_vector *payload = DMNSN_MALLOC(dmnsn_vector);
*payload = dmnsn_vector_normalized(orientation);
gradient->pattern_fn = dmnsn_gradient_pattern_fn;
diff --git a/libdimension/interior.c b/libdimension/interior.c
index 24797a6..791d31a 100644
--- a/libdimension/interior.c
+++ b/libdimension/interior.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -30,7 +30,7 @@
dmnsn_interior *
dmnsn_new_interior(void)
{
- dmnsn_interior *interior = dmnsn_malloc(sizeof(dmnsn_interior));
+ dmnsn_interior *interior = DMNSN_MALLOC(dmnsn_interior);
interior->ior = 1.0;
interior->free_fn = NULL;
DMNSN_REFCOUNT_INIT(interior);
diff --git a/libdimension/lambertian.c b/libdimension/lambertian.c
index 16dc910..17bed6d 100644
--- a/libdimension/lambertian.c
+++ b/libdimension/lambertian.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -43,7 +43,7 @@ dmnsn_new_lambertian(double diffuse)
{
dmnsn_diffuse *lambertian = dmnsn_new_diffuse();
- double *param = dmnsn_malloc(sizeof(double));
+ double *param = DMNSN_MALLOC(double);
*param = diffuse;
lambertian->diffuse_fn = dmnsn_lambertian_diffuse_fn;
diff --git a/libdimension/light.c b/libdimension/light.c
index d64b2a2..fdb65bd 100644
--- a/libdimension/light.c
+++ b/libdimension/light.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -30,7 +30,7 @@
dmnsn_light *
dmnsn_new_light(void)
{
- dmnsn_light *light = dmnsn_malloc(sizeof(dmnsn_light));
+ dmnsn_light *light = DMNSN_MALLOC(dmnsn_light);
light->direction_fn = NULL;
light->illumination_fn = NULL;
light->shadow_fn = NULL;
diff --git a/libdimension/map.c b/libdimension/map.c
index 37f3c0f..963f170 100644
--- a/libdimension/map.c
+++ b/libdimension/map.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -34,7 +34,7 @@ typedef struct dmnsn_map_entry {
dmnsn_map *
dmnsn_new_map(size_t size)
{
- dmnsn_map *map = dmnsn_malloc(sizeof(dmnsn_map));
+ dmnsn_map *map = DMNSN_MALLOC(dmnsn_map);
map->free_fn = NULL;
map->obj_size = size;
map->array = dmnsn_new_array(sizeof(dmnsn_map_entry) + size);
diff --git a/libdimension/object.c b/libdimension/object.c
index 9792926..b085cff 100644
--- a/libdimension/object.c
+++ b/libdimension/object.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -30,7 +30,7 @@
dmnsn_object *
dmnsn_new_object(void)
{
- dmnsn_object *object = dmnsn_malloc(sizeof(dmnsn_object));
+ dmnsn_object *object = DMNSN_MALLOC(dmnsn_object);
object->texture = NULL;
object->interior = NULL;
object->trans = dmnsn_identity_matrix();
diff --git a/libdimension/pattern.c b/libdimension/pattern.c
index f32671c..2a7dca6 100644
--- a/libdimension/pattern.c
+++ b/libdimension/pattern.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -29,7 +29,7 @@
dmnsn_pattern *
dmnsn_new_pattern(void)
{
- dmnsn_pattern *pattern = dmnsn_malloc(sizeof(dmnsn_pattern));
+ dmnsn_pattern *pattern = DMNSN_MALLOC(dmnsn_pattern);
pattern->free_fn = NULL;
DMNSN_REFCOUNT_INIT(pattern);
return pattern;
diff --git a/libdimension/pigment.c b/libdimension/pigment.c
index bc09ec7..6134c2b 100644
--- a/libdimension/pigment.c
+++ b/libdimension/pigment.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -29,7 +29,7 @@
dmnsn_pigment *
dmnsn_new_pigment(void)
{
- dmnsn_pigment *pigment = dmnsn_malloc(sizeof(dmnsn_pigment));
+ dmnsn_pigment *pigment = DMNSN_MALLOC(dmnsn_pigment);
pigment->pigment_fn = NULL;
pigment->initialize_fn = NULL;
pigment->free_fn = NULL;
diff --git a/libdimension/pigment_map.c b/libdimension/pigment_map.c
index f34be5a..b8d7b12 100644
--- a/libdimension/pigment_map.c
+++ b/libdimension/pigment_map.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -104,8 +104,7 @@ dmnsn_new_pigment_map_pigment(dmnsn_pattern *pattern, dmnsn_map *map,
{
dmnsn_pigment *pigment = dmnsn_new_pigment();
- dmnsn_pigment_map_payload *payload
- = dmnsn_malloc(sizeof(dmnsn_pigment_map_payload));
+ dmnsn_pigment_map_payload *payload = DMNSN_MALLOC(dmnsn_pigment_map_payload);
payload->pattern = pattern;
payload->map = map;
payload->flags = flags;
diff --git a/libdimension/plane.c b/libdimension/plane.c
index 5710a9f..33d2737 100644
--- a/libdimension/plane.c
+++ b/libdimension/plane.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -41,7 +41,7 @@ dmnsn_new_plane(dmnsn_vector normal)
{
dmnsn_object *plane = dmnsn_new_object();
- dmnsn_vector *param = dmnsn_malloc(sizeof(dmnsn_vector));
+ dmnsn_vector *param = DMNSN_MALLOC(dmnsn_vector);
*param = normal;
plane->intersection_fn = dmnsn_plane_intersection_fn;
diff --git a/libdimension/png.c b/libdimension/png.c
index ab5ea5c..b83aaf6 100644
--- a/libdimension/png.c
+++ b/libdimension/png.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -72,8 +72,7 @@ dmnsn_png_write_canvas_async(const dmnsn_canvas *canvas, FILE *file)
{
dmnsn_future *future = dmnsn_new_future();
- dmnsn_png_write_payload *payload
- = dmnsn_malloc(sizeof(dmnsn_png_write_payload));
+ dmnsn_png_write_payload *payload = DMNSN_MALLOC(dmnsn_png_write_payload);
payload->future = future;
payload->canvas = canvas;
payload->file = file;
@@ -99,8 +98,7 @@ dmnsn_future *
dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, FILE *file)
{
dmnsn_future *future = dmnsn_new_future();
- dmnsn_png_read_payload *payload
- = dmnsn_malloc(sizeof(dmnsn_png_write_payload));
+ dmnsn_png_read_payload *payload = DMNSN_MALLOC(dmnsn_png_write_payload);
payload->future = future;
payload->canvas = canvas;
diff --git a/libdimension/point_light.c b/libdimension/point_light.c
index a840843..6b5639d 100644
--- a/libdimension/point_light.c
+++ b/libdimension/point_light.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -60,8 +60,7 @@ dmnsn_new_point_light(dmnsn_vector x0, dmnsn_color color)
{
dmnsn_light *light = dmnsn_new_light();
- dmnsn_point_light_payload *payload
- = dmnsn_malloc(sizeof(dmnsn_point_light_payload));
+ dmnsn_point_light_payload *payload = DMNSN_MALLOC(dmnsn_point_light_payload);
payload->origin = x0;
payload->color = color;
light->ptr = payload;
diff --git a/libdimension/ray_trace.c b/libdimension/ray_trace.c
index c9f7da4..d7383e4 100644
--- a/libdimension/ray_trace.c
+++ b/libdimension/ray_trace.c
@@ -56,8 +56,7 @@ dmnsn_ray_trace_async(dmnsn_scene *scene)
{
dmnsn_future *future = dmnsn_new_future();
- dmnsn_ray_trace_payload *payload =
- dmnsn_malloc(sizeof(dmnsn_ray_trace_payload));
+ dmnsn_ray_trace_payload *payload = DMNSN_MALLOC(dmnsn_ray_trace_payload);
payload->future = future;
payload->scene = scene;
diff --git a/libdimension/reflection.c b/libdimension/reflection.c
index 7c82112..934fcf6 100644
--- a/libdimension/reflection.c
+++ b/libdimension/reflection.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -53,8 +53,7 @@ dmnsn_new_basic_reflection(dmnsn_color min, dmnsn_color max, double falloff)
{
dmnsn_reflection *reflection = dmnsn_new_reflection();
- dmnsn_reflection_params *params
- = dmnsn_malloc(sizeof(dmnsn_reflection_params));
+ dmnsn_reflection_params *params = DMNSN_MALLOC(dmnsn_reflection_params);
params->min = min;
params->max = max;
params->falloff = falloff;
diff --git a/libdimension/scene.c b/libdimension/scene.c
index 3e3a9f2..9f8104b 100644
--- a/libdimension/scene.c
+++ b/libdimension/scene.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -30,7 +30,7 @@
dmnsn_scene *
dmnsn_new_scene(void)
{
- dmnsn_scene *scene = dmnsn_malloc(sizeof(dmnsn_scene));
+ dmnsn_scene *scene = DMNSN_MALLOC(dmnsn_scene);
scene->background = NULL;
scene->default_texture = dmnsn_new_texture();
diff --git a/libdimension/tests/display.c b/libdimension/tests/display.c
index d4e2a1c..133eb25 100644
--- a/libdimension/tests/display.c
+++ b/libdimension/tests/display.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -52,7 +52,7 @@ dmnsn_new_display(const dmnsn_canvas *canvas)
XSetWindowAttributes swa;
dmnsn_display *display;
- display = dmnsn_malloc(sizeof(dmnsn_display));
+ display = DMNSN_MALLOC(dmnsn_display);
display->dpy = NULL;
display->win = 0;
diff --git a/libdimension/tests/refcount.c b/libdimension/tests/refcount.c
index efceacd..68d7c1d 100644
--- a/libdimension/tests/refcount.c
+++ b/libdimension/tests/refcount.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2012 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2012-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -32,7 +32,7 @@ typedef struct dmnsn_foo {
static dmnsn_foo *
dmnsn_new_foo(void)
{
- dmnsn_foo *foo = dmnsn_malloc(sizeof(dmnsn_foo));
+ dmnsn_foo *foo = DMNSN_MALLOC(dmnsn_foo);
DMNSN_REFCOUNT_INIT(foo);
return foo;
}
diff --git a/libdimension/texture.c b/libdimension/texture.c
index 24ff9af..516a50b 100644
--- a/libdimension/texture.c
+++ b/libdimension/texture.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -29,7 +29,7 @@
dmnsn_texture *
dmnsn_new_texture(void)
{
- dmnsn_texture *texture = dmnsn_malloc(sizeof(dmnsn_texture));
+ dmnsn_texture *texture = DMNSN_MALLOC(dmnsn_texture);
texture->pigment = NULL;
texture->finish = dmnsn_new_finish();
texture->trans = dmnsn_identity_matrix();
diff --git a/libdimension/threads.c b/libdimension/threads.c
index 85832b9..539a3f9 100644
--- a/libdimension/threads.c
+++ b/libdimension/threads.c
@@ -52,7 +52,7 @@ dmnsn_thread(void *arg)
int *ret;
pthread_cleanup_push(dmnsn_thread_cleanup, payload);
- ret = dmnsn_malloc(sizeof(int));
+ ret = DMNSN_MALLOC(int);
*ret = payload->thread_fn(payload->arg);
pthread_cleanup_pop(true);
return ret;
@@ -61,7 +61,7 @@ dmnsn_thread(void *arg)
void
dmnsn_new_thread(dmnsn_future *future, dmnsn_thread_fn *thread_fn, void *arg)
{
- dmnsn_thread_payload *payload = dmnsn_malloc(sizeof(dmnsn_thread_payload));
+ dmnsn_thread_payload *payload = DMNSN_MALLOC(dmnsn_thread_payload);
payload->thread_fn = thread_fn;
payload->arg = arg;
payload->future = future;
diff --git a/libdimension/torus.c b/libdimension/torus.c
index 0ef8e92..67bed0f 100644
--- a/libdimension/torus.c
+++ b/libdimension/torus.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2013 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -152,7 +152,7 @@ dmnsn_new_torus(double major, double minor)
minor,
major + minor);
- dmnsn_torus_payload *payload = dmnsn_malloc(sizeof(dmnsn_torus_payload));
+ dmnsn_torus_payload *payload = DMNSN_MALLOC(dmnsn_torus_payload);
payload->major = major;
payload->minor = minor;
torus->ptr = payload;
diff --git a/libdimension/triangle.c b/libdimension/triangle.c
index a176414..8ae7629 100644
--- a/libdimension/triangle.c
+++ b/libdimension/triangle.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -72,8 +72,7 @@ dmnsn_new_triangle(dmnsn_vector a, dmnsn_vector b, dmnsn_vector c,
nb = dmnsn_vector_normalized(nb);
nc = dmnsn_vector_normalized(nc);
- dmnsn_triangle_payload *payload =
- dmnsn_malloc(sizeof(dmnsn_triangle_payload));
+ dmnsn_triangle_payload *payload = DMNSN_MALLOC(dmnsn_triangle_payload);
payload->a = a;
payload->na = na;
payload->ab = dmnsn_vector_sub(b, a);