]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - util.c
util_swa_* + GMQCC_INLINE
[xonotic/gmqcc.git] / util.c
diff --git a/util.c b/util.c
index 32b487ed94360126578d94a82980061d3619c220..f4dbfc4b21a65d759bbc2c81da800b6c1be9b1cb 100644 (file)
--- a/util.c
+++ b/util.c
@@ -42,7 +42,7 @@ struct memblock_t {
 static struct memblock_t *mem_start = NULL;
 
 void *util_memory_a(size_t byte, unsigned int line, const char *file) {
-    struct memblock_t *info = malloc(sizeof(struct memblock_t) + byte);
+    struct memblock_t *info = (struct memblock_t*)malloc(sizeof(struct memblock_t) + byte);
     void              *data = (void*)(info+1);
     if (!info) return NULL;
     info->line = line;
@@ -170,7 +170,7 @@ char *util_strdup(const char *s) {
     if (!s)
         return NULL;
 
-    if ((len = strlen(s)) && (ptr = mem_a(len+1))) {
+    if ((len = strlen(s)) && (ptr = (char*)mem_a(len+1))) {
         memcpy(ptr, s, len);
         ptr[len] = '\0';
     }
@@ -196,13 +196,13 @@ void util_debug(const char *area, const char *ms, ...) {
  * data.
  */   
 #if PLATFORM_BYTE_ORDER == GMQCC_BYTE_ORDER_BIG
-    static void util_swap16(uint16_t *d, size_t l) {
+    static GMQCC_INLINE void util_swap16(uint16_t *d, size_t l) {
         while (l--) {
             d[l] = (d[l] << 8) | (d[l] >> 8);
         }
     }
 
-    static void util_swap32(uint32_t *d, size_t l) {
+    static GMQCC_INLINE void util_swap32(uint32_t *d, size_t l) {
         while (l--) {
             uint32_t v;
             v = ((d[l] << 8) & 0xFF00FF00) | ((d[l] >> 8) & 0x00FF00FF);
@@ -213,7 +213,7 @@ void util_debug(const char *area, const char *ms, ...) {
     /* Some strange system doesn't like constants that big, AND doesn't recognize an ULL suffix
      * so let's go the safe way
      */
-    static void util_swap64(uint32_t *d, size_t l) {
+    static GMQCC_INLINE void util_swap64(uint32_t *d, size_t l) {
         /*
         while (l--) {
             uint64_t v;
@@ -426,7 +426,7 @@ GMQCC_INLINE size_t util_hthash(hash_table_t *ht, const char *key) {
 
 hash_node_t *_util_htnewpair(const char *key, void *value) {
     hash_node_t *node;
-    if (!(node = mem_a(sizeof(hash_node_t))))
+    if (!(node = (hash_node_t*)mem_a(sizeof(hash_node_t))))
         return NULL;
 
     if (!(node->key = util_strdup(key))) {
@@ -452,10 +452,10 @@ hash_table_t *util_htnew(size_t size) {
     if (size < 1)
         return NULL;
 
-    if (!(hashtable = mem_a(sizeof(hash_table_t))))
+    if (!(hashtable = (hash_table_t*)mem_a(sizeof(hash_table_t))))
         return NULL;
 
-    if (!(hashtable->table = mem_a(sizeof(hash_node_t*) * size))) {
+    if (!(hashtable->table = (hash_node_t**)mem_a(sizeof(hash_node_t*) * size))) {
         mem_d(hashtable);
         return NULL;
     }