Skip to content

Commit

Permalink
Merge PR #110 with uintptr_t detection
Browse files Browse the repository at this point in the history
  • Loading branch information
LB-- committed Nov 3, 2021
2 parents 24df9ad + 9083578 commit b10ff61
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions json.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
#include <limits.h>
#include <math.h>

#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 might give us uintptr_t and UINTPTR_MAX but they also might not be provided */
#include <stdint.h>
#endif

#ifndef JSON_INT_T_OVERRIDDEN
#if defined(_MSC_VER)
/* https://docs.microsoft.com/en-us/cpp/cpp/data-type-ranges */
Expand Down Expand Up @@ -160,7 +165,11 @@ static int new_value (json_state * state,
values_size = sizeof (*value->u.object.values) * value->u.object.length;

if (! (value->u.object.values = (json_object_entry *) json_alloc
#ifdef UINTPTR_MAX
(state, values_size + ((uintptr_t) value->u.object.values), 0)) )
#else
(state, values_size + ((size_t) value->u.object.values), 0)) )
#endif
{
return 0;
}
Expand Down

0 comments on commit b10ff61

Please sign in to comment.