Make HashMap and Json conform to C89.

Clang on OpenBSD didn't catch this, but GCC on Linux did.
This commit is contained in:
Jordan Bancino 2022-07-27 09:47:22 -04:00
parent e232fd683e
commit bc849819d9
4 changed files with 11 additions and 13 deletions

View file

@ -1,12 +1,11 @@
#include <HashMap.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
typedef struct HashMapBucket
{
uint32_t hash;
unsigned long hash;
char *key;
void *value;
} HashMapBucket;
@ -21,15 +20,15 @@ struct HashMap
size_t iterator;
};
static uint32_t
static unsigned long
HashMapHashKey(const char *key)
{
uint32_t hash = 2166136261u;
unsigned long hash = 2166136261u;
size_t i = 0;
while (key[i])
{
hash ^= (uint8_t) key[i];
hash ^= (unsigned char) key[i];
hash *= 16777619;
i++;
@ -128,7 +127,7 @@ HashMapCreate(void)
void *
HashMapDelete(HashMap * map, const char *key)
{
uint32_t hash;
unsigned long hash;
size_t index;
if (!map || !key)
@ -182,7 +181,7 @@ HashMapFree(HashMap * map)
void *
HashMapGet(HashMap * map, const char *key)
{
uint32_t hash;
unsigned long hash;
size_t index;
if (!map || !key)
@ -262,7 +261,7 @@ HashMapMaxLoadSet(HashMap * map, float load)
void *
HashMapSet(HashMap * map, char *key, void *value)
{
uint32_t hash;
unsigned long hash;
size_t index;
if (!map || !key || !value)

View file

@ -12,7 +12,7 @@ struct JsonValue
HashMap *object;
Array *array;
char *string;
int64_t integer;
long integer;
double floating;
int boolean:1;
} as;
@ -137,7 +137,7 @@ JsonValueAsString(JsonValue * value)
}
JsonValue *
JsonValueInteger(int64_t integer)
JsonValueInteger(long integer)
{
JsonValue *value;
@ -427,7 +427,7 @@ JsonEncodeValue(JsonValue * value, FILE * out)
JsonEncodeString(value->as.string, out);
break;
case JSON_INTEGER:
fprintf(out, "%lld", value->as.integer);
fprintf(out, "%ld", value->as.integer);
break;
case JSON_FLOAT:
fprintf(out, "%f", value->as.floating);

View file

@ -6,7 +6,6 @@
#include <Log.h>
#include <HashMap.h>
#include <Config.h>
#include <Base64.h>
typedef enum ArgFlag
{

View file

@ -39,7 +39,7 @@ extern JsonValue *
JsonValueString(char *string);
extern JsonValue *
JsonValueInteger(int64_t integer);
JsonValueInteger(long integer);
extern JsonValue *
JsonValueFloat(double floating);