summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/shape.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-27 19:57:09 +0200
committerTyge Løvset <[email protected]>2023-03-27 19:57:09 +0200
commite35036deef4fc8f17cc9221e2e666dfdb832ba78 (patch)
treeb41e45015be7454ef3f82092b558da6b365d6a57 /misc/examples/shape.c
parentede39bc98a758674485796174ea860515ec281e6 (diff)
downloadSTC-modified-e35036deef4fc8f17cc9221e2e666dfdb832ba78.tar.gz
STC-modified-e35036deef4fc8f17cc9221e2e666dfdb832ba78.zip
More RAII cleanup in examples. Also removed gauss1.c and new_deq.c
Diffstat (limited to 'misc/examples/shape.c')
-rw-r--r--misc/examples/shape.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/misc/examples/shape.c b/misc/examples/shape.c
index 2aabdcc2..e24f7fd7 100644
--- a/misc/examples/shape.c
+++ b/misc/examples/shape.c
@@ -139,23 +139,23 @@ void testShape(const Shape* shape)
int main(void)
{
Shapes shapes = {0};
- c_defer (Shapes_drop(&shapes))
- {
- Triangle* tri1 = c_new(Triangle, Triangle_from((Point){5, 7}, (Point){12, 7}, (Point){12, 20}));
- Polygon* pol1 = c_new(Polygon, Polygon_init());
- Polygon* pol2 = c_new(Polygon, Polygon_init());
-
- c_forlist (i, Point, {{50, 72}, {123, 73}, {127, 201}, {828, 333}})
- Polygon_addPoint(pol1, *i.ref);
-
- c_forlist (i, Point, {{5, 7}, {12, 7}, {12, 20}, {82, 33}, {17, 56}})
- Polygon_addPoint(pol2, *i.ref);
-
- Shapes_push(&shapes, &tri1->shape);
- Shapes_push(&shapes, &pol1->shape);
- Shapes_push(&shapes, &pol2->shape);
-
- c_foreach (i, Shapes, shapes)
- testShape(*i.ref);
- }
+
+ Triangle* tri1 = c_new(Triangle, Triangle_from((Point){5, 7}, (Point){12, 7}, (Point){12, 20}));
+ Polygon* pol1 = c_new(Polygon, Polygon_init());
+ Polygon* pol2 = c_new(Polygon, Polygon_init());
+
+ c_forlist (i, Point, {{50, 72}, {123, 73}, {127, 201}, {828, 333}})
+ Polygon_addPoint(pol1, *i.ref);
+
+ c_forlist (i, Point, {{5, 7}, {12, 7}, {12, 20}, {82, 33}, {17, 56}})
+ Polygon_addPoint(pol2, *i.ref);
+
+ Shapes_push(&shapes, &tri1->shape);
+ Shapes_push(&shapes, &pol1->shape);
+ Shapes_push(&shapes, &pol2->shape);
+
+ c_foreach (i, Shapes, shapes)
+ testShape(*i.ref);
+
+ Shapes_drop(&shapes);
}