diff options
author | Mattias Andrée <maandree@kth.se> | 2023-02-05 01:49:25 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-02-05 01:49:25 +0100 |
commit | 32c96afc3c2c78e15c0e05560b4e08f8cdc2437e (patch) | |
tree | 3b4f9b8588cfb574ef420bc5667c3d4a177b58d3 /rtgrpblib_create_raster.c | |
download | librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-32c96afc3c2c78e15c0e05560b4e08f8cdc2437e.tar.gz librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-32c96afc3c2c78e15c0e05560b4e08f8cdc2437e.tar.bz2 librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-32c96afc3c2c78e15c0e05560b4e08f8cdc2437e.tar.xz |
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | rtgrpblib_create_raster.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/rtgrpblib_create_raster.c b/rtgrpblib_create_raster.c new file mode 100644 index 0000000..89ebad6 --- /dev/null +++ b/rtgrpblib_create_raster.c @@ -0,0 +1,40 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +RASTER * +rtgrpblib_create_raster(size_t width, size_t height) +{ + RASTER *raster; + + if (!width || !height) { + errno = EINVAL; + return NULL; + } + + if (width > (SIZE_MAX - offsetof(RASTER, cells)) / sizeof(*raster->cells) / height) + goto enomem; + raster = calloc(1, offsetof(RASTER, cells) + height * width * sizeof(*raster->cells)); + if (!raster) { + enomem: + errno = ENOMEM; + return NULL; + } + + raster->width = width; + raster->height = height; + raster->draftness = 0.5; + return raster; +} + + +#else + +int +main(void) +{ + return 0; /* TODO add test */ +} + +#endif |