make some function parameters const

Tue, 09 Sep 2025 16:14:11 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 09 Sep 2025 16:14:11 +0200
changeset 753
882e49cf7192
parent 752
08a2421957f1
child 754
fb5f560e81d9

make some function parameters const

ui/common/properties.c file | annotate | diff | comparison | revisions
ui/ui/properties.h file | annotate | diff | comparison | revisions
ui/ui/toolkit.h file | annotate | diff | comparison | revisions
--- a/ui/common/properties.c	Mon Sep 08 12:43:52 2025 +0200
+++ b/ui/common/properties.c	Tue Sep 09 16:14:11 2025 +0200
@@ -73,7 +73,7 @@
 #define UI_ENV_HOME "USERPROFILE"
 #endif
 
-char* ui_configfile(char *name) {
+char* ui_configfile(const char *name) {
     const char *appname = ui_appname();
     if(!appname) {
         return NULL;
@@ -241,12 +241,14 @@
 
 #ifndef UI_COCOA
 
-void ui_locales_dir(char *path) {
-    locales_dir = path;
+void ui_locales_dir(const char *path) {
+    free(locales_dir);
+    locales_dir = path ? strdup(path) : NULL;
 }
 
-void ui_pixmaps_dir(char *path) {
-    pixmaps_dir = path;
+void ui_pixmaps_dir(const char *path) {
+    free(pixmaps_dir);
+    pixmaps_dir = path ? strdup(path) : NULL;
 }
 
 char* uic_get_image_path(const char *imgfilename) {
@@ -257,7 +259,7 @@
     }
 }
 
-void ui_load_lang(char *locale) {
+void ui_load_lang(const char *locale) {
     if(!locale) {
         locale = "en_EN";
     }
@@ -319,12 +321,12 @@
     return 0;
 }
 
-char* uistr(char *name) {
+char* uistr(const char *name) {
     char *value = uistr_n(name);
     return value ? value : "missing string";
 }
 
-char* uistr_n(char *name) {
+char* uistr_n(const char *name) {
     if(!language) {
         return NULL;
     }
--- a/ui/ui/properties.h	Mon Sep 08 12:43:52 2025 +0200
+++ b/ui/ui/properties.h	Tue Sep 09 16:14:11 2025 +0200
@@ -41,14 +41,14 @@
 
 int ui_properties_store(void);
 
-void ui_locales_dir(char *path);
-void ui_pixmaps_dir(char *path);
+void ui_locales_dir(const char *path);
+void ui_pixmaps_dir(const char *path);
 
-void ui_load_lang(char *locale);
+void ui_load_lang(const char *locale);
 void ui_load_lang_def(char *locale, char *default_locale);
     
-char* uistr(char *name);
-char* uistr_n(char *name);
+char* uistr(const char *name);
+char* uistr_n(const char *name);
 
 #ifdef	__cplusplus
 }
--- a/ui/ui/toolkit.h	Mon Sep 08 12:43:52 2025 +0200
+++ b/ui/ui/toolkit.h	Tue Sep 09 16:14:11 2025 +0200
@@ -672,7 +672,7 @@
 
 
 UIEXPORT char* ui_getappdir(void);
-UIEXPORT char* ui_configfile(char *name);
+UIEXPORT char* ui_configfile(const char *name);
 
 UIEXPORT UiCondVar* ui_condvar_create(void);
 UIEXPORT void ui_condvar_wait(UiCondVar *var);

mercurial