aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2024-04-20 01:59:31 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2024-04-20 01:59:31 -0400
commite421022ffbe502bb44393d4a437056a952924cb8 (patch)
tree07b0044a99b37b64fdc2112d9873f2831f5a802a
parenta6f125eae289a00dec324e139d64002fae14bcfb (diff)
updated multiple types to const
-rw-r--r--src/plotting.c16
-rw-r--r--src/plotting.h10
2 files changed, 13 insertions, 13 deletions
diff --git a/src/plotting.c b/src/plotting.c
index 96d76c5..5b5565e 100644
--- a/src/plotting.c
+++ b/src/plotting.c
@@ -5,8 +5,8 @@
/*
* Gets the corresponding color for a given number of iterations according to a gradient
*/
-color get_color(size_t iterations, size_t max_iterations, gradient map){
- size_t val = (max_iterations - iterations) / max_iterations;
+color get_color(const size_t iterations, const size_t max_iterations, const gradient map){
+ const size_t val = (max_iterations - iterations) / max_iterations;
color color;
//TODO: map the interval of [0,max_iterations] to a value given a gradient
@@ -16,7 +16,7 @@ color get_color(size_t iterations, size_t max_iterations, gradient map){
/*
* Gets the associated "red" value for a given number of iterations according to a gradient
*/
-char get_red(size_t iterations, size_t max_iterations, gradient map){
+char get_red(const size_t iterations, const size_t max_iterations, const gradient map){
char red;
return red;
@@ -25,7 +25,7 @@ char get_red(size_t iterations, size_t max_iterations, gradient map){
/*
* Gets the associated "green" value for a given number of iterations according to a gradient
*/
-char get_green(size_t iterations, size_t max_iterations, gradient map){
+char get_green(const size_t iterations, const size_t max_iterations, const gradient map){
char green;
return green;
@@ -34,13 +34,13 @@ char get_green(size_t iterations, size_t max_iterations, gradient map){
/*
* Gets the associated "blue" value for a given number of iterations according to a gradient
*/
-char get_blue(size_t iterations, size_t max_iterations, gradient map){
+char get_blue(const size_t iterations, const size_t max_iterations, const gradient map){
char blue;
return blue;
}
-colors_t* create_colors(size_t x, size_t y){
+colors_t* create_colors(const size_t x, const size_t y){
if(x <= 0 || y <= 0) return NULL;
char* red = malloc(x*y);
@@ -68,8 +68,8 @@ colors_t* create_colors(size_t x, size_t y){
return colors;
}
-colors_t* copy_colors(colors_t* colors){
- if(!colors) return NULL;
+colors_t* copy_colors(const colors_t* colors){
+ if(!colors || !colors->red || !colors->green || !colors->blue) return NULL;
colors_t* colors_copy = create_colors(colors->x, colors->y);
if(!colors_copy) return NULL;
diff --git a/src/plotting.h b/src/plotting.h
index 9d72b69..d94c7bc 100644
--- a/src/plotting.h
+++ b/src/plotting.h
@@ -20,12 +20,12 @@ typedef struct {
typedef char gradient;
// for AoS
-color get_color(size_t iterations, size_t max_iterations, gradient map);
+color get_color(const size_t iterations, const size_t max_iterations, const gradient map);
// for SoA
-char get_red(size_t iterations, size_t max_iterations, gradient map);
-char get_green(size_t iterations, size_t max_iterations, gradient map);
-char get_blue(size_t iterations, size_t max_iterations, gradient map);
+char get_red(const size_t iterations, const size_t max_iterations, const gradient map);
+char get_green(const size_t iterations, const size_t max_iterations, const gradient map);
+char get_blue(const size_t iterations, const size_t max_iterations, const gradient map);
colors_t* create_colors(size_t x, size_t y);
-colors_t* copy_colors(colors_t* colors);
+colors_t* copy_colors(const colors_t* colors);
void free_colors(colors_t* colors);