From 337ac77c1b098b5e0c277acfe3558f8e75a8d3cf Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 20 Jun 2021 11:34:35 -0700 Subject: [PATCH] fix: incorrect failure diagnosis in lab_gamut_quadtree call This function can only fail due to exhausting memory, not due to the lab_gamut file failing to be opened. As per the previous commit, this file is no longer relevant as the gamut information is in the source itself. --- CHANGELOG.md | 2 ++ lib/edgepaint/node_distinct_coloring.c | 4 ++-- lib/edgepaint/node_distinct_coloring.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12bccb3a3..fa3350aa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ortho's eqEndSeg incorrectly modifies its arguments #2047 - Autotools enables -Wtrampolines and -Wlogical-op for Clang #2066 +- node_distinct_coloring failure due to out-of-memory now reported correctly + instead of referring to a failure to open lab_gamut ## [2.47.3] - 2021-06-19 diff --git a/lib/edgepaint/node_distinct_coloring.c b/lib/edgepaint/node_distinct_coloring.c index 7c17d9dbd..61e210d10 100644 --- a/lib/edgepaint/node_distinct_coloring.c +++ b/lib/edgepaint/node_distinct_coloring.c @@ -249,8 +249,8 @@ void node_distinct_coloring(char *color_scheme, char *lightness, int weightedQ, scheme = COLOR_LAB; qt = lab_gamut_quadtree(lightness, max_qtree_level); if (!qt){ - fprintf(stderr," can not open file \"lab_gamut\"\n"); - *flag = ERROR_BAD_LAB_GAMUT_FILE; + fprintf(stderr, "out of memory\n"); + *flag = -1; return; } } else if (strcmp(color_scheme, "rgb") == 0){ diff --git a/lib/edgepaint/node_distinct_coloring.h b/lib/edgepaint/node_distinct_coloring.h index 6d47d3455..7a5dc6913 100644 --- a/lib/edgepaint/node_distinct_coloring.h +++ b/lib/edgepaint/node_distinct_coloring.h @@ -12,7 +12,7 @@ #define NODE_DISTINCT_COLORING_H enum {COLOR_RGB, COLOR_GRAY, COLOR_LAB}; -enum {ERROR_BAD_LAB_GAMUT_FILE = -10, ERROR_BAD_COLOR_SCHEME = -9}; +enum {ERROR_BAD_COLOR_SCHEME = -9}; void node_distinct_coloring(char *color_scheme, char *lightness, int weightedQ, SparseMatrix A, real accuracy, int iter_max, int seed, int *cdim, real **colors, real *color_diff, real *color_diff_sum, int *flag); #endif -- 2.40.0