@@ -90,6 +90,12 @@ typedef struct __LongLongValue
9090 long long value ;
9191} LongLongValue ;
9292
93+ typedef struct __UnsignedLongLongValue
94+ {
95+ Item item ;
96+ unsigned long long value ;
97+ } UnsignedLongLongValue ;
98+
9399typedef struct __DoubleValue
94100{
95101 Item item ;
@@ -143,6 +149,9 @@ static void *alloc(struct DecoderState *ds, size_t cbSize)
143149 newSize *= 2 ;
144150
145151 newSlab = (HeapSlab * ) ds -> malloc (newSize );
152+ if (! newSlab ) {
153+ return NULL ;
154+ }
146155 newSlab -> start = (unsigned char * ) (newSlab + 1 );
147156 newSlab -> end = (unsigned char * ) newSlab + newSize ;
148157 newSlab -> size = newSize ;
@@ -297,6 +306,18 @@ static JSOBJ newLong(void *context, JSINT64 value)
297306 return (JSOBJ ) llv ;
298307}
299308
309+ static JSOBJ newUnsignedLong (void * context , JSUINT64 value )
310+ {
311+ struct DecoderState * ds = context ;
312+ UnsignedLongLongValue * llv =
313+ (UnsignedLongLongValue * ) alloc (ds , sizeof (UnsignedLongLongValue ));
314+ if (llv ) {
315+ llv -> item .type = UJT_UnsignedLongLong ;
316+ llv -> value = (long long unsigned ) value ;
317+ }
318+ return (JSOBJ ) llv ;
319+ }
320+
300321static JSOBJ newDouble (void * context , double value )
301322{
302323 struct DecoderState * ds = context ;
@@ -329,6 +350,11 @@ static long long GetLongLong(UJObject obj)
329350 return ((LongLongValue * ) obj )-> value ;
330351}
331352
353+ static unsigned long long GetUnsignedLongLong (UJObject obj )
354+ {
355+ return ((UnsignedLongLongValue * ) obj )-> value ;
356+ }
357+
332358void UJFree (void * state )
333359{
334360 struct DecoderState * ds = (struct DecoderState * ) state ;
@@ -518,12 +544,27 @@ int UJIterObject(void **iter, UJString *outKey, UJObject *outValue)
518544 return 1 ;
519545}
520546
547+ unsigned long long UJNumericUnsignedLongLong (UJObject obj )
548+ {
549+ switch ( ((Item * ) obj )-> type )
550+ {
551+ case UJT_Long : return (unsigned long long ) GetLong (obj );
552+ case UJT_LongLong : return (unsigned long long ) GetLongLong (obj );
553+ case UJT_UnsignedLongLong : return GetUnsignedLongLong (obj );
554+ case UJT_Double : return (unsigned long long ) GetDouble (obj );
555+ default : break ;
556+ }
557+
558+ return 0 ;
559+ }
560+
521561long long UJNumericLongLong (UJObject obj )
522562{
523563 switch ( ((Item * ) obj )-> type )
524564 {
525565 case UJT_Long : return (long long ) GetLong (obj );
526566 case UJT_LongLong : return (long long ) GetLongLong (obj );
567+ case UJT_UnsignedLongLong : return (long long ) GetUnsignedLongLong (obj );
527568 case UJT_Double : return (long long ) GetDouble (obj );
528569 default : break ;
529570 }
@@ -537,6 +578,7 @@ int UJNumericInt(UJObject obj)
537578 {
538579 case UJT_Long : return (int ) GetLong (obj );
539580 case UJT_LongLong : return (int ) GetLongLong (obj );
581+ case UJT_UnsignedLongLong : return (int ) GetUnsignedLongLong (obj );
540582 case UJT_Double : return (int ) GetDouble (obj );
541583 default : break ;
542584 }
@@ -550,6 +592,7 @@ double UJNumericFloat(UJObject obj)
550592 {
551593 case UJT_Long : return (double ) GetLong (obj );
552594 case UJT_LongLong : return (double ) GetLongLong (obj );
595+ case UJT_UnsignedLongLong : return (double ) GetUnsignedLongLong (obj );
553596 case UJT_Double : return (double ) GetDouble (obj );
554597 default : break ;
555598 }
@@ -781,6 +824,7 @@ UJObject UJDecode(const char *input, size_t cbInput, UJHeapFuncs *hf, void **out
781824 newArray ,
782825 newInt ,
783826 newLong ,
827+ newUnsignedLong ,
784828 newDouble ,
785829 releaseObject ,
786830 NULL ,
0 commit comments