mirror of
https://github.com/rafagafe/tiny-json.git
synced 2025-03-12 19:25:30 +00:00
Merge pull request #5 from jurgen178/jurgen178-patch-1
Jurgen178 patch 1
This commit is contained in:
commit
93f3b61eb0
@ -61,7 +61,7 @@ char const* json_getPropertyValue( json_t const* obj, char const* property ) {
|
|||||||
static char* goBlank( char* str );
|
static char* goBlank( char* str );
|
||||||
static char* goNum( char* str );
|
static char* goNum( char* str );
|
||||||
static json_t* poolInit( jsonPool_t* pool );
|
static json_t* poolInit( jsonPool_t* pool );
|
||||||
static json_t* poolNew( jsonPool_t* pool );
|
static json_t* poolAlloc( jsonPool_t* pool );
|
||||||
static char* objValue( char* ptr, json_t* obj, jsonPool_t* pool );
|
static char* objValue( char* ptr, json_t* obj, jsonPool_t* pool );
|
||||||
static char* setToNull( char* ch );
|
static char* setToNull( char* ch );
|
||||||
static bool isEndOfPrimitive( char ch );
|
static bool isEndOfPrimitive( char ch );
|
||||||
@ -86,7 +86,7 @@ json_t const* json_create( char* str, json_t mem[], unsigned int qty ) {
|
|||||||
.qty = qty,
|
.qty = qty,
|
||||||
.pool = {
|
.pool = {
|
||||||
.init = poolInit,
|
.init = poolInit,
|
||||||
.new = poolNew
|
.alloc = poolAlloc
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return json_createWithPool( str, &spool.pool );
|
return json_createWithPool( str, &spool.pool );
|
||||||
@ -348,7 +348,7 @@ static char* objValue( char* ptr, json_t* obj, jsonPool_t* pool ) {
|
|||||||
++ptr;
|
++ptr;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
json_t* property = pool->new( pool );
|
json_t* property = pool->alloc( pool );
|
||||||
if ( !property ) return 0;
|
if ( !property ) return 0;
|
||||||
if( obj->type != JSON_ARRAY ) {
|
if( obj->type != JSON_ARRAY ) {
|
||||||
if ( *ptr != '\"' ) return 0;
|
if ( *ptr != '\"' ) return 0;
|
||||||
@ -396,7 +396,7 @@ static json_t* poolInit( jsonPool_t* pool ) {
|
|||||||
* @param pool The handler of the pool.
|
* @param pool The handler of the pool.
|
||||||
* @retval The handler of the new instance if success.
|
* @retval The handler of the new instance if success.
|
||||||
* @retval Null pointer if the pool was empty. */
|
* @retval Null pointer if the pool was empty. */
|
||||||
static json_t* poolNew( jsonPool_t* pool ) {
|
static json_t* poolAlloc( jsonPool_t* pool ) {
|
||||||
jsonStaticPool_t *spool = json_containerOf( pool, jsonStaticPool_t, pool );
|
jsonStaticPool_t *spool = json_containerOf( pool, jsonStaticPool_t, pool );
|
||||||
if ( spool->nextFree >= spool->qty ) return 0;
|
if ( spool->nextFree >= spool->qty ) return 0;
|
||||||
return spool->mem + spool->nextFree++;
|
return spool->mem + spool->nextFree++;
|
||||||
|
@ -156,7 +156,7 @@ static inline double json_getReal( json_t const* property ) {
|
|||||||
typedef struct jsonPool_s jsonPool_t;
|
typedef struct jsonPool_s jsonPool_t;
|
||||||
struct jsonPool_s {
|
struct jsonPool_s {
|
||||||
json_t* (*init)( jsonPool_t* pool );
|
json_t* (*init)( jsonPool_t* pool );
|
||||||
json_t* (*new)( jsonPool_t* pool );
|
json_t* (*alloc)( jsonPool_t* pool );
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Parse a string to get a json.
|
/** Parse a string to get a json.
|
||||||
|
Loading…
Reference in New Issue
Block a user