photomosaics

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 188e1179ed6fcbc5a3d8b335c343f1c5607b2830
parent 742359317f9897041422dd1254495596731f45e9
Author: Wilson Gheen <wilson@wilsonrgheen.com>
Date:   Tue, 17 Jan 2023 15:15:41 -0600

Define initial deletables size as a macro

Diffstat:
Mphotomosaics.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/photomosaics.c b/photomosaics.c @@ -24,6 +24,7 @@ typedef enum { L, UL, XU, XUL, F } NUM_TYPES; #define MAX_FN_LEN 150 #define IMG_LIST_MAX_SIZE 5091 +#define DELETABLES_INITIAL_SIZE 50 static const char *cache_filename = "/home/wilson/.cache/photomosaics/avgs"; static char *cache_buf = NULL; @@ -159,7 +160,7 @@ static ssize_t cache_grep(char *key) { /* The following 2 mallocs are guesses; will realloc later if needed */ cache_max_size = (cache_file_size < 5822 ? 5822 : cache_file_size) + 5 * MAX_FN_LEN; cache_buf = malloc(cache_max_size); - deletables = malloc(50 * sizeof(long)); + deletables = malloc(DELETABLES_INITIAL_SIZE * sizeof(long)); initial_cache_size = cache_size = fread(cache_buf, 1, cache_file_size, cache_file); cache_buf[cache_size] = 0; /* For the initial strncat later */ @@ -204,7 +205,7 @@ static ssize_t cache_grep(char *key) { } /* Not up to date. Caller will create a new cache entry, then we will delete this line at the end of the program */ - if(deletables_ind > 49) { + if(deletables_ind >= DELETABLES_INITIAL_SIZE) { deletables = realloc(deletables, (deletables_ind + 1) * sizeof(deletables[0])); assert_error(deletables, "realloc"); }