summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-01-17 12:12:01 -0500
committerAndrew Opalach <andrew@akon.city> 2025-01-17 12:12:01 -0500
commit37684729283f62fd7f1e74bc2b318dc9ad2cb695 (patch)
tree2f5be73bf64ac6573e35e8f499515659472a14c9 /src/util
parentd1f1eb9b3713a450c0736caad17febae0721af4d (diff)
downloadcamu-37684729283f62fd7f1e74bc2b318dc9ad2cb695.tar.gz
camu-37684729283f62fd7f1e74bc2b318dc9ad2cb695.tar.bz2
camu-37684729283f62fd7f1e74bc2b318dc9ad2cb695.zip
Account for dependency changes, platform testing
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/color_palette.c14
-rw-r--r--src/util/queue.h45
2 files changed, 34 insertions, 25 deletions
diff --git a/src/util/color_palette.c b/src/util/color_palette.c
index bb4da03..886ba8e 100644
--- a/src/util/color_palette.c
+++ b/src/util/color_palette.c
@@ -40,24 +40,32 @@ bool camu_color_palette_init(str *path)
nn_file_read_as_str(&file, &s);
nn_file_close(&file);
json_error_t error;
- json_t *root = json_loadb(s.data, s.len, 0, &error);
+ json_t *root = json_loadb(s.data, s.length, 0, &error);
if (!root) return false;
json_t *special = json_object_get(root, "special");
json_t *colors = json_object_get(root, "colors");
if (!special || !colors) return false;
json_t *object;
+ bool to_long_error;
const char *color;
+ u32 value;
for (u32 i = 0; i < ARRAY_SIZE(special_colors); i++) {
object = json_object_get(special, special_colors[i]);
if (!object) return false;
color = json_string_value(object);
- global_color_palette.colors[i] = (u32)al_str_to_long(al_str_w((char *)color, 1, 6), 16);
+ value = (u32)al_str_to_long(&al_str_w((char *)color, 1, 6), 16, &to_long_error);
+ if (!to_long_error) {
+ global_color_palette.colors[i] = value;
+ }
}
for (u32 i = 0; i < ARRAY_SIZE(normal_colors); i++) {
object = json_object_get(colors, normal_colors[i]);
if (!object) return false;
color = json_string_value(object);
- global_color_palette.colors[i + 2] = (u32)al_str_to_long(al_str_w((char *)color, 1, 6), 16);
+ value = (u32)al_str_to_long(&al_str_w((char *)color, 1, 6), 16, &to_long_error);
+ if (!to_long_error) {
+ global_color_palette.colors[i + 2] = value;
+ }
}
return true;
}
diff --git a/src/util/queue.h b/src/util/queue.h
index bd91342..d103831 100644
--- a/src/util/queue.h
+++ b/src/util/queue.h
@@ -11,59 +11,60 @@
#define camu_queue_lock(q) \
AL_MACRO_WRAP \
-({ \
+{ \
nn_mutex_lock(&(q).mutex); \
-})
+} AL_MACRO_END
#define camu_queue_unlock(q) \
AL_MACRO_WRAP \
-({ \
+{ \
nn_mutex_unlock(&(q).mutex); \
-})
+} AL_MACRO_END
-#define camu_queue_size(q, r) \
+#define camu_queue_count(q, r) \
AL_MACRO_WRAP \
-({ \
+{ \
nn_mutex_lock(&(q).mutex); \
- r = (q).a.size; \
+ r = (q).a.count; \
nn_mutex_unlock(&(q).mutex); \
-})
+} AL_MACRO_END
#define camu_queue_init(q) \
AL_MACRO_WRAP \
-({ \
+{ \
al_array_init((q).a); \
nn_mutex_init(&(q).mutex); \
-})
+} AL_MACRO_END
#define camu_queue_push(q, item) \
AL_MACRO_WRAP \
-({ \
+{ \
nn_mutex_lock(&(q).mutex); \
al_array_push((q).a, item); \
nn_mutex_unlock(&(q).mutex); \
-})
+} AL_MACRO_END
#define camu_queue_pop(q, r) \
AL_MACRO_WRAP \
-({ \
+{ \
nn_mutex_lock(&(q).mutex); \
al_array_pop_at((q).a, 0, r); \
nn_mutex_unlock(&(q).mutex); \
-})
+} AL_MACRO_END
#define camu_queue_try_pop(q, s, r) \
-AL_MACRO_WRAP \
-({ \
- nn_mutex_lock(&(q).mutex); \
- if ((s = (q).a.size) > 0) \
+AL_MACRO_WRAP \
+{ \
+ nn_mutex_lock(&(q).mutex); \
+ if ((s = (q).a.count) > 0) { \
al_array_pop_at((q).a, 0, r); \
- nn_mutex_unlock(&(q).mutex); \
-})
+ } \
+ nn_mutex_unlock(&(q).mutex); \
+} AL_MACRO_END
#define camu_queue_free(q) \
AL_MACRO_WRAP \
-({ \
+{ \
nn_mutex_destroy(&(q).mutex); \
al_array_free((q).a); \
-})
+} AL_MACRO_END