Merge pull request #359 from Haffon/api-0.12

update CMakeLists.txt for compile with visual studio at least 2010
This commit is contained in:
Eric Haszlakiewicz
2017-09-06 23:20:36 -04:00
committed by GitHub
6 changed files with 29 additions and 11 deletions

View File

@@ -52,6 +52,8 @@ set(JSON_C_HEADERS
./linkhash.h
./math_compat.h
./strdup_compat.h
./strerror_override.h
./strerror_override_private.h
./vasprintf_compat.h
./printbuf.h
./random_seed.h
@@ -66,6 +68,7 @@ set(JSON_C_SOURCES
./json_util.c
./linkhash.c
./printbuf.c
./strerror_override.c
./random_seed.c
./strerror_override.c
)

View File

@@ -459,13 +459,15 @@ int json_object_object_add_ex(struct json_object* jso,
struct json_object *const val,
const unsigned opts)
{
struct json_object *existing_value = NULL;
struct lh_entry *existing_entry;
unsigned long hash;
assert(json_object_get_type(jso) == json_type_object);
// We lookup the entry and replace the value, rather than just deleting
// and re-adding it, so the existing key remains valid.
json_object *existing_value = NULL;
struct lh_entry *existing_entry;
const unsigned long hash = lh_get_hash(jso->o.c_object, (const void *)key);
hash = lh_get_hash(jso->o.c_object, (const void *)key);
existing_entry = (opts & JSON_C_OBJECT_ADD_KEY_IS_NEW) ? NULL :
lh_table_lookup_entry_w_hash(jso->o.c_object,
(const void *)key, hash);
@@ -851,11 +853,12 @@ struct json_object* json_object_new_double(double d)
struct json_object* json_object_new_double_s(double d, const char *ds)
{
char *new_ds;
struct json_object *jso = json_object_new_double(d);
if (!jso)
return NULL;
char *new_ds = strdup(ds);
new_ds = strdup(ds);
if (!new_ds)
{
json_object_generic_delete(jso);
@@ -1035,8 +1038,8 @@ int json_object_set_string(json_object* jso, const char* s) {
}
int json_object_set_string_len(json_object* jso, const char* s, int len){
if (jso==NULL || jso->o_type!=json_type_string) return 0;
char *dstbuf;
if (jso==NULL || jso->o_type!=json_type_string) return 0;
if (len<LEN_DIRECT_STRING_DATA) {
dstbuf=jso->o.c_string.str.data;
if (jso->o.c_string.len>=LEN_DIRECT_STRING_DATA) free(jso->o.c_string.str.ptr);

View File

@@ -387,10 +387,11 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
{
size_t size_inf;
int is_negative = 0;
char *infbuf;
printbuf_memappend_fast(tok->pb, &c, 1);
size_inf = json_min(tok->st_pos+1, json_inf_str_len);
char *infbuf = tok->pb->buf;
infbuf = tok->pb->buf;
if (*infbuf == '-')
{
infbuf++;

View File

@@ -560,6 +560,13 @@ int lh_table_resize(struct lh_table *t, int new_size)
return 0;
}
#if defined(_MSC_VER) && (_MSC_VER < 1900)
unsigned long lh_get_hash(const struct lh_table *t, const void *k)
{
return t->hash_fn(k);
}
#endif
void lh_table_free(struct lh_table *t)
{
struct lh_entry *c;

View File

@@ -332,10 +332,14 @@ int lh_table_resize(struct lh_table *t, int new_size);
* @param k a pointer to the key to lookup
* @return the key's hash
*/
static inline unsigned long lh_get_hash(const struct lh_table *t, const void *k)
{
return t->hash_fn(k);
#if !defined(_MSC_VER) || (_MSC_VER > 1800)
static inline unsigned long lh_get_hash(const struct lh_table *t, const void *k)
{
return t->hash_fn(k);
}
#else
unsigned long lh_get_hash(const struct lh_table *t, const void *k);
#endif
/* Don't use this outside of linkhash.h: */
#ifdef __UNCONST

View File

@@ -186,11 +186,11 @@ static int get_dev_random_seed()
static int get_cryptgenrandom_seed()
{
DEBUG_SEED("get_cryptgenrandom_seed");
HCRYPTPROV hProvider = 0;
int r;
DEBUG_SEED("get_cryptgenrandom_seed");
if (!CryptAcquireContextW(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
fprintf(stderr, "error CryptAcquireContextW");
exit(1);