makes g++ happy again

Thu, 21 Jun 2018 16:10:19 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 21 Jun 2018 16:10:19 +0200
changeset 328
2bf1da3c411e
parent 327
fbc33813265b
child 329
71e9a60abfb4

makes g++ happy again

src/logging.c file | annotate | diff | comparison | revisions
src/map.c file | annotate | diff | comparison | revisions
src/ucx/string.h file | annotate | diff | comparison | revisions
src/ucx/utils.h file | annotate | diff | comparison | revisions
--- a/src/logging.c	Thu Jun 21 16:00:37 2018 +0200
+++ b/src/logging.c	Thu Jun 21 16:10:19 2018 +0200
@@ -71,12 +71,12 @@
         const unsigned int line, const char *format, ...) {
     if (level <= logger->level) {
         char msg[UCX_LOGGER_MSGMAX];
-        char *text;
+        const char *text;
         size_t k = 0;
         size_t n;
         
         if ((logger->mask & UCX_LOGGER_LEVEL) > 0) {
-            text = (char*) ucx_map_int_get(logger->levels, level);
+            text = (const char*) ucx_map_int_get(logger->levels, level);
             if (!text) {
                 text = "[UNKNOWN]";
             }
--- a/src/map.c	Thu Jun 21 16:00:37 2018 +0200
+++ b/src/map.c	Thu Jun 21 16:10:19 2018 +0200
@@ -154,7 +154,7 @@
     UcxAllocator *allocator = map->allocator;
     
     if (key.hash == 0) {
-        key.hash = ucx_hash(key.data, key.len);
+        key.hash = ucx_hash((const char*)key.data, key.len);
     }
     
     struct UcxMapKey mapkey;
@@ -203,7 +203,7 @@
 
 static void* ucx_map_get_and_remove(UcxMap *map, UcxKey key, int remove) {
     if(key.hash == 0) {
-        key.hash = ucx_hash((char*)key.data, key.len);
+        key.hash = ucx_hash((const char*)key.data, key.len);
     }
     
     size_t slot = key.hash%map->size;
@@ -247,7 +247,7 @@
     UcxKey key;
     key.data = data;
     key.len = len;
-    key.hash = ucx_hash(data, len);
+    key.hash = ucx_hash((const char*)data, len);
     return key;
 }
 
--- a/src/ucx/string.h	Thu Jun 21 16:00:37 2018 +0200
+++ b/src/ucx/string.h	Thu Jun 21 16:10:19 2018 +0200
@@ -124,7 +124,7 @@
 inline scstr_t s2scstr(sstr_t s) {
     scstr_t c;
     c.ptr = s.ptr;
-    c.length = s.ptr;
+    c.length = s.length;
     return c;
 }
 
--- a/src/ucx/utils.h	Thu Jun 21 16:00:37 2018 +0200
+++ b/src/ucx/utils.h	Thu Jun 21 16:10:19 2018 +0200
@@ -38,10 +38,6 @@
 #ifndef UCX_UTILS_H
 #define UCX_UTILS_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include "ucx.h"
 #include "string.h"
 #include "allocator.h"
@@ -49,6 +45,10 @@
 #include <string.h>
 #include <stdarg.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**
  * Default buffer size for ucx_stream_copy() and ucx_stream_ncopy().
  */

mercurial