diff options
| author | Sopár Adrián <dev.adrian.sopar@protonmail.com> | 2023-01-27 00:05:24 +0100 |
|---|---|---|
| committer | Sopár Adrián <dev.adrian.sopar@protonmail.com> | 2023-01-27 00:05:24 +0100 |
| commit | 2c5a5f7679a5f450e483fdedc99c80622f260a4d (patch) | |
| tree | c96f4f9020275e8853c92f008fa9f041e0529a57 /v1/shape.c | |
Diffstat (limited to 'v1/shape.c')
| -rw-r--r-- | v1/shape.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/v1/shape.c b/v1/shape.c new file mode 100644 index 0000000..eb5e399 --- /dev/null +++ b/v1/shape.c @@ -0,0 +1,32 @@ +#include <stdlib.h> +#include "shape.h" + +struct shape +{ + void *obj; + shape_area_t area; + shape_destroy_t destroy; +}; + +double shape_area(struct shape *shape) +{ + return shape->area(shape->obj); +} + +void shape_destroy(struct shape *shape) +{ + shape->destroy(shape->obj); + free(shape); +} + +struct shape *shape_create( + void *obj, + shape_area_t area, + shape_destroy_t destroy) +{ + struct shape *shape = malloc(sizeof(shape)); + shape->obj = obj; + shape->area = area; + shape->destroy = destroy; + return shape; +}
\ No newline at end of file |
