{"action":"created","issue":{"url":"https://api.github.com/repos/EsotericSoftware/spine-runtimes/issues/391","repository_url":"https://api.github.com/repos/EsotericSoftware/spine-runtimes","labels_url":"https://api.github.com/repos/EsotericSoftware/spine-runtimes/issues/391/labels{/name}","comments_url":"https://api.github.com/repos/EsotericSoftware/spine-runtimes/issues/391/comments","events_url":"https://api.github.com/repos/EsotericSoftware/spine-runtimes/issues/391/events","html_url":"https://github.com/EsotericSoftware/spine-runtimes/issues/391","id":62392582,"number":391,"title":"json.c take up a lost of memory","user":{"login":"jxnczyp","id":5689673,"avatar_url":"https://avatars.githubusercontent.com/u/5689673?v=3","gravatar_id":"","url":"https://api.github.com/users/jxnczyp","html_url":"https://github.com/jxnczyp","followers_url":"https://api.github.com/users/jxnczyp/followers","following_url":"https://api.github.com/users/jxnczyp/following{/other_user}","gists_url":"https://api.github.com/users/jxnczyp/gists{/gist_id}","starred_url":"https://api.github.com/users/jxnczyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jxnczyp/subscriptions","organizations_url":"https://api.github.com/users/jxnczyp/orgs","repos_url":"https://api.github.com/users/jxnczyp/repos","events_url":"https://api.github.com/users/jxnczyp/events{/privacy}","received_events_url":"https://api.github.com/users/jxnczyp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/EsotericSoftware/spine-runtimes/labels/runtimes","name":"runtimes","color":"bfd4f2"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2015-03-17T13:14:39Z","updated_at":"2016-07-18T13:18:37Z","closed_at":"2016-07-18T13:18:37Z","body":"\r\n/*\r\n Copyright (c) 2009 Dave Gamble\r\n \r\n Permission is hereby granted, dispose of charge, to any person obtaining a copy\r\n of this software and associated documentation files (the \"Software\"), to deal\r\n in the Software without restriction, including without limitation the rights\r\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n copies of the Software, and to permit persons to whom the Software is\r\n furnished to do so, subject to the following conditions:\r\n \r\n The above copyright notice and this permission notice shall be included in\r\n all copies or substantial portions of the Software.\r\n \r\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n THE SOFTWARE.\r\n */\r\n\r\n/* Esoteric Software: Removed everything except parsing, shorter method names, more get methods, double to float, formatted. */\r\n\r\n#ifndef SPINE_JSON_H_\r\n#define SPINE_JSON_H_\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n/* Json Types: */\r\n#define Json_False 0\r\n#define Json_True 1\r\n#define Json_NULL 2\r\n#define Json_Number 3\r\n#define Json_String 4\r\n#define Json_Array 5\r\n#define Json_Object 6\r\n\r\n\r\n#define EJGET_ARR_SIZE(item) *((int*)(item) - 1)\r\n\r\n/* The Json structure: */\r\n\r\n\r\nstruct JsonObjEntry;\r\n\r\ntypedef struct Json {\r\n// \tstruct Json* next;\r\n// \tstruct Json* prev; /* next/prev allow you to walk array/object chains. Alternatively, use getSize/getItem */\r\n// \tstruct Json* child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */\r\n// \r\n// \tint type; /* The type of the item, as above. */\r\n// \tint size; /* The number of children. */\r\n// \r\n// \tconst char* valueString; /* The item's string, if type==Json_String */\r\n// \tint valueInt; /* The item's number, if type==Json_Number */\r\n// \tfloat valueFloat; /* The item's number, if type==Json_Number */\r\n// \r\n// \tconst char* name; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */\r\n\r\n\tint type;\r\n\tunion\r\n\t{\r\n\t\tfloat numberVal;\r\n\t\tint boolVal;\r\n\t\tconst char* strVal;\r\n\t\tstruct JsonObjEntry* objVals;\r\n\t\tstruct Json* arrVals;\r\n\t};\r\n} Json;\r\n\r\ntypedef struct JsonObjEntry{\r\n\tconst char* name;\r\n\tJson val;\r\n}JsonObjEntry;\r\n\r\n/* Supply a block of JSON, and this returns a Json object you can interrogate. Call Json_dispose when finished. */\r\nJson* Json_create (const char* value);\r\n\r\n/* Delete a Json entity and all subentities. */\r\nvoid Json_dispose (Json* json);\r\n\r\n/* Get item \"string\" from object. Case insensitive. */\r\nJson* Json_getItem (Json* json, const char* string);\r\nJsonObjEntry* Json_getItemEntry (Json* json, const char* string);\r\nconst char* Json_getString (Json* json, const char* name, const char* defaultValue);\r\nfloat Json_getFloat (Json* json, const char* name, float defaultValue);\r\nint Json_getInt (Json* json, const char* name, int defaultValue);\r\n\r\n/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when Json_create() returns 0. 0 when Json_create() succeeds. */\r\nconst char* Json_getError (void);\r\n\r\nint Json_getCount(Json* data);\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif /* SPINE_JSON_H_ */\r\n\r\n\r\n\r\n/*\r\n Copyright (c) 2009 Dave Gamble\r\n\r\n Permission is hereby granted, dispose of charge, to any person obtaining a copy\r\n of this software and associated documentation files (the \"Software\"), to deal\r\n in the Software without restriction, including without limitation the rights\r\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n copies of the Software, and to permit persons to whom the Software is\r\n furnished to do so, subject to the following conditions:\r\n\r\n The above copyright notice and this permission notice shall be included in\r\n all copies or substantial portions of the Software.\r\n\r\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n THE SOFTWARE.\r\n */\r\n\r\n/* Json */\r\n/* JSON parser in C. */\r\n\r\n#include \"Json.h\"\r\n#include <stdio.h>\r\n#include <memory.h>\r\n#include <stdlib.h>\r\n#include <ctype.h>\r\n#include <math.h>\r\n\r\n#include \"extension.h\"\r\n\r\n\r\nstatic const char* ep;\r\n\r\n// first int use for capacity second int use for size, return = head + 2*sizeof*\r\n#define EJMALLOC_ARR(type, count) (type*)((char*)CALLOC(char, sizeof(int) * 2 + sizeof(type) * count ) + sizeof(int) * 2)\r\n\r\n#define EJFREE_ARR(item) free((char*)(item) - 2 * sizeof(int))\r\n\r\n#define EJSET_ARR_SIZE(item, size) *((int*)(item) - 1) = size\r\n\r\n#define EJGET_ARR_CAPACITY(item) *((int*)(item) - 2)\r\n\r\n#define EJSET_ARR_CAPACITY(item, size) *((int*)(item) - 2) = size\r\n\r\nchar* EJRemallocArr(char* oldData, size_t oldTypeSize, size_t newSize){\r\n\tint size = EJGET_ARR_SIZE(oldData);\r\n\tsize_t allocSize = oldTypeSize * newSize + 2 * sizeof(int);\r\n\tchar* oldDataRealPos = oldData - 2 * sizeof(int);\r\n\tchar* newData = (char*)realloc(oldDataRealPos, allocSize) + 2 * sizeof(int);\r\n\tmemset(newData + oldTypeSize * size, 0, (newSize - size) * oldTypeSize);\r\n\treturn newData;\r\n}\r\n\r\nconst char* Json_getError (void) {\r\n\treturn ep;\r\n}\r\n\r\nstatic int Json_strcasecmp (const char* s1, const char* s2) {\r\n\tif (!s1) return (s1 == s2) ? 0 : 1;\r\n\tif (!s2) return 1;\r\n\tfor (; tolower(*s1) == tolower(*s2); ++s1, ++s2)\r\n\t\tif (*s1 == 0) return 0;\r\n\treturn tolower(*(const unsigned char*)s1) - tolower(*(const unsigned char*)s2);\r\n}\r\n\r\n/* Internal constructor. */\r\nstatic Json *Json_new (void) {\r\n\treturn (Json*)CALLOC(Json, 1);\r\n}\r\n\r\n/* Delete a Json structure. */\r\nstatic void __Json_dispose_all (Json *c) {\r\n\tif (c == NULL){\r\n\t\treturn;\r\n\t}\r\n\tif (c->type == Json_Array)\r\n\t{\r\n\t\tint size = EJGET_ARR_SIZE(c->arrVals);\r\n\t\tint i = 0;\r\n\t\tfor(i = 0; i < size; i++){\r\n\t\t\tJson* child = &c->arrVals[i];\r\n\t\t\t__Json_dispose_all(child);\r\n\t\t}\r\n\t\tEJFREE_ARR(c->arrVals);\r\n\t}\r\n\telse if(c->type == Json_Object)\r\n\t{\r\n\t\tif (c->objVals){\r\n\t\t\tint size = EJGET_ARR_SIZE(c->objVals);\r\n\t\t\tint i = 0;\r\n\t\t\tfor(i = 0; i < size; i++){\r\n\t\t\t\tJsonObjEntry* child = & c->objVals[i];;\r\n                __Json_dispose_all(&child->val);\r\n\t\t\t}\r\n            EJFREE_ARR(c->objVals);\r\n\t\t}\r\n\t}\r\n\telse if (c->type == Json_String){\r\n\r\n\t}\r\n}\r\n\r\nvoid Json_dispose (Json *c) {\r\n\t__Json_dispose_all(c);\r\n\tFREE(c);\r\n}\r\n\r\n/* Parse the input text to generate a number, and populate the result into item. */\r\nstatic const char* parse_number (Json *item, const char* num) {\r\n\tfloat n = 0, sign = 1, scale = 0;\r\n\tint subscale = 0, signsubscale = 1;\r\n\r\n\t/* Could use sscanf for this? */\r\n\tif (*num == '-') sign = -1, num++; /* Has sign? */\r\n\tif (*num == '0') num++; /* is zero */\r\n\tif (*num >= '1' && *num <= '9') do\r\n\t\tn = (n * 10.0f) + (*num++ - '0');\r\n\twhile (*num >= '0' && *num <= '9'); /* Number? */\r\n\tif (*num == '.' && num[1] >= '0' && num[1] <= '9') {\r\n\t\tnum++;\r\n\t\tdo\r\n\t\t\tn = (n * 10.0f) + (*num++ - '0'), scale--;\r\n\t\twhile (*num >= '0' && *num <= '9');\r\n\t} /* Fractional part? */\r\n\tif (*num == 'e' || *num == 'E') /* Exponent? */\r\n\t{\r\n\t\tnum++;\r\n\t\tif (*num == '+')\r\n\t\t\tnum++;\r\n\t\telse if (*num == '-') signsubscale = -1, num++; /* With sign? */\r\n\t\twhile (*num >= '0' && *num <= '9')\r\n\t\t\tsubscale = (subscale * 10) + (*num++ - '0'); /* Number? */\r\n\t}\r\n\r\n\tn = sign * n * (float)pow(10.0f, (scale + subscale * signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */\r\n\r\n\titem->numberVal = n;\r\n\titem->type = Json_Number;\r\n\treturn num;\r\n}\r\n\r\n/* Parse the input text into an unescaped cstring, and populate item. */\r\nstatic const unsigned char firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};\r\nstatic const char* parse_string (Json *item, const char* str) {\r\n\tconst char* ptr = str + 1;\r\n\tchar* ptr2;\r\n\tchar* out;\r\n\tint len = 0;\r\n\tunsigned uc, uc2;\r\n\tif (*str != '\\\"') {\r\n\t\tep = str;\r\n\t\treturn 0;\r\n\t} /* not a string! */\r\n\r\n\twhile (*ptr != '\\\"' && *ptr && ++len)\r\n\t\tif (*ptr++ == '\\\\') ptr++; /* Skip escaped quotes. */\r\n\r\n//\tout = MALLOC(char, len + 1); /* The length needed for the string, roughly. */ zyptmp\r\n//\tif (!out) return 0; zyptmp\r\n\r\n\tptr = str + 1;\r\n\tout = ptr2 = (char*)ptr;\r\n\twhile (*ptr != '\\\"' && *ptr) {\r\n\t\tif (*ptr != '\\\\')\r\n\t\t\t*ptr2++ = *ptr++;\r\n\t\telse {\r\n\t\t\tptr++;\r\n\t\t\tswitch (*ptr) {\r\n\t\t\tcase 'b':\r\n\t\t\t\t*ptr2++ = '\\b';\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'f':\r\n\t\t\t\t*ptr2++ = '\\f';\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'n':\r\n\t\t\t\t*ptr2++ = '\\n';\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'r':\r\n\t\t\t\t*ptr2++ = '\\r';\r\n\t\t\t\tbreak;\r\n\t\t\tcase 't':\r\n\t\t\t\t*ptr2++ = '\\t';\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'u': /* transcode utf16 to utf8. */\r\n\t\t\t\tsscanf(ptr + 1, \"%4x\", &uc);\r\n\t\t\t\tptr += 4; /* get the unicode char. */\r\n\r\n\t\t\t\tif ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) break; /* check for invalid.\t*/\r\n\r\n\t\t\t\tif (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs.\t*/\r\n\t\t\t\t{\r\n\t\t\t\t\tif (ptr[1] != '\\\\' || ptr[2] != 'u') break; /* missing second-half of surrogate.\t*/\r\n\t\t\t\t\tsscanf(ptr + 3, \"%4x\", &uc2);\r\n\t\t\t\t\tptr += 6;\r\n\t\t\t\t\tif (uc2 < 0xDC00 || uc2 > 0xDFFF) break; /* invalid second-half of surrogate.\t*/\r\n\t\t\t\t\tuc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tlen = 4;\r\n\t\t\t\tif (uc < 0x80)\r\n\t\t\t\t\tlen = 1;\r\n\t\t\t\telse if (uc < 0x800)\r\n\t\t\t\t\tlen = 2;\r\n\t\t\t\telse if (uc < 0x10000) len = 3;\r\n\t\t\t\tptr2 += len;\r\n\r\n\t\t\t\tswitch (len) {\r\n\t\t\t\tcase 4:\r\n\t\t\t\t\t*--ptr2 = ((uc | 0x80) & 0xBF);\r\n\t\t\t\t\tuc >>= 6;\r\n\t\t\t\tcase 3:\r\n\t\t\t\t\t*--ptr2 = ((uc | 0x80) & 0xBF);\r\n\t\t\t\t\tuc >>= 6;\r\n\t\t\t\tcase 2:\r\n\t\t\t\t\t*--ptr2 = ((uc | 0x80) & 0xBF);\r\n\t\t\t\t\tuc >>= 6;\r\n\t\t\t\tcase 1:\r\n\t\t\t\t\t*--ptr2 = (uc | firstByteMark[len]);\r\n\t\t\t\t}\r\n\t\t\t\tptr2 += len;\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\t*ptr2++ = *ptr;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tptr++;\r\n\t\t}\r\n\t}\r\n\t\r\n\tif (*ptr == '\\\"') ptr++;\r\n\t*ptr2 = 0;\r\n\titem->strVal = out;\r\n\titem->type = Json_String;\r\n\treturn ptr;\r\n}\r\n\r\n/* Predeclare these prototypes. */\r\nstatic const char* parse_value (Json *item, const char* value);\r\nstatic const char* parse_array (Json *item, const char* value);\r\nstatic const char* parse_object (Json *item, const char* value);\r\n\r\n/* Utility to jump whitespace and cr/lf */\r\nstatic const char* skip (const char* in) {\r\n\twhile (in && *in && (unsigned char)*in <= 32)\r\n\t\tin++;\r\n\treturn in;\r\n}\r\n\r\n/* Parse an object - create a new root, and populate. */\r\nJson *Json_create (const char* value) {\r\n\tconst char* end = 0;\r\n\tJson *c = Json_new();\r\n\tep = 0;\r\n\tif (!c) return 0; /* memory fail */\r\n\r\n\tend = parse_value(c, skip(value));\r\n\tif (!end) {\r\n\t\tJson_dispose(c);\r\n\t\treturn 0;\r\n\t} /* parse failure. ep is set. */\r\n\r\n\treturn c;\r\n}\r\n\r\n/* Parser core - when encountering text, process appropriately. */\r\nstatic const char* parse_value (Json *item, const char* value) {\r\n\tif (!value) return 0; /* Fail on null. */\r\n\tif (!strncmp(value, \"null\", 4)) {\r\n\t\titem->type = Json_NULL;\r\n\t\treturn value + 4;\r\n\t}\r\n\tif (!strncmp(value, \"false\", 5)) {\r\n\t\titem->type = Json_False;\r\n\t\titem->boolVal = 0;\r\n\t\treturn value + 5;\r\n\t}\r\n\tif (!strncmp(value, \"true\", 4)) {\r\n\t\titem->type = Json_True;\r\n\t\titem->boolVal = 1;\r\n\t\treturn value + 4;\r\n\t}\r\n\tif (*value == '\\\"') {\r\n\t\treturn parse_string(item, value);\r\n\t}\r\n\tif (*value == '-' || (*value >= '0' && *value <= '9')) {\r\n\t\treturn parse_number(item, value);\r\n\t}\r\n\tif (*value == '[') {\r\n\t\treturn parse_array(item, value);\r\n\t}\r\n\tif (*value == '{') {\r\n\t\treturn parse_object(item, value);\r\n\t}\r\n\r\n\tep = value;\r\n\treturn 0; /* failure. */\r\n}\r\n\r\n/* Build an array from input text. */\r\nstatic const char* parse_array (Json *item, const char* value) {\r\n\tJson *child;\r\n\tif (*value != '[') {\r\n\t\tep = value;\r\n\t\treturn 0;\r\n\t} /* not an array! */\r\n\r\n\titem->type = Json_Array;\r\n\tvalue = skip(value + 1);\r\n\tif (*value == ']') return value + 1; /* empty array. */\r\n\r\n\t\r\n\titem->arrVals = child = EJMALLOC_ARR(Json,2);\r\n\tif (!child) return 0; /* memory fail */\r\n\tEJSET_ARR_SIZE(item->arrVals, 0);\r\n\tvalue = skip(parse_value(child, skip(value))); /* skip any spacing, get the value. */\r\n\tif (!value) return 0;\r\n\tEJSET_ARR_CAPACITY(item->arrVals, 2);\r\n\tEJSET_ARR_SIZE(item->arrVals, 1);\r\n//\titem->size = 1;\r\n\r\n\twhile (*value == ',') {\r\n\t\tint capacity = EJGET_ARR_CAPACITY(item->arrVals);\r\n\t\tint size = EJGET_ARR_SIZE(item->arrVals);\r\n\t\tJson *new_item = NULL;\r\n\t\tif (size >= capacity){\r\n\t\t\tint newCapacity = capacity * 3 / 2 + 1;\r\n\t\t\titem->arrVals = (Json*)EJRemallocArr((char*)item->arrVals, sizeof(Json), newCapacity);\r\n\t\t\tEJSET_ARR_CAPACITY(item->arrVals, newCapacity);\r\n\t\t\tEJSET_ARR_SIZE(item->arrVals, size);\r\n\t\t}\r\n\t\tnew_item = &item->arrVals[size];\r\n//\t\tif (!(new_item = Json_new())) return 0; /* memory fail */\r\n//\t\tchild->next = new_item;\r\n//\t\tnew_item->prev = child;\r\n\t\tchild = new_item;\r\n\t\tvalue = skip(parse_value(child, skip(value + 1)));\r\n\t\tif (!value) return 0; /* memory fail */\r\n\t\tsize++;\r\n\t\tEJSET_ARR_SIZE(item->arrVals, size);\r\n//\t\titem->size++;\r\n\t}\r\n\t\r\n\r\n\tif (*value == ']') return value + 1; /* end of array */\r\n\tep = value;\r\n\treturn 0; /* malformed. */\r\n}\r\n\r\n/* Build an object from the text. */\r\nstatic const char* parse_object (Json *item, const char* value) {\r\n\tJsonObjEntry *child;\r\n\tJson strTmp;\r\n\tif (*value != '{') {\r\n\t\tep = value;\r\n\t\treturn 0;\r\n\t} /* not an object! */\r\n\r\n\titem->type = Json_Object;\r\n\tvalue = skip(value + 1);\r\n\tif (*value == '}') return value + 1; /* empty array. */\r\n\r\n\titem->objVals = child = (JsonObjEntry*)EJMALLOC_ARR(JsonObjEntry, 2);;\r\n\tif (!item->objVals) return 0;\r\n\tEJSET_ARR_CAPACITY(item->objVals, 2);\r\n\tEJSET_ARR_SIZE(item->objVals, 0);\r\n\tvalue = skip(parse_string(&strTmp, skip(value)));\r\n\tif (!value) return 0;\r\n\tchild->name = strTmp.strVal;\r\n\r\n\tif (*value != ':') {\r\n\t\tep = value;\r\n\t\treturn 0;\r\n\t} /* fail! */\r\n\tvalue = skip(parse_value(&child->val, skip(value + 1))); /* skip any spacing, get the value. */\r\n\tif (!value) return 0;\r\n\tEJSET_ARR_SIZE(item->objVals, 1);\r\n//\titem->size = 1;\r\n\r\n\t\r\n\twhile (*value == ',') {\r\n\t\tint capacity = EJGET_ARR_CAPACITY(item->objVals);\r\n\t\tint size = EJGET_ARR_SIZE(item->objVals);\r\n\t\tif (size >= capacity){\r\n\t\t\tint newCapacity = capacity * 3 / 2 + 1;\r\n\t\t\titem->objVals = (JsonObjEntry*)EJRemallocArr((char*)item->objVals, sizeof(JsonObjEntry), newCapacity);\r\n\t\t\tEJSET_ARR_CAPACITY(item->objVals, newCapacity);\r\n\t\t\tEJSET_ARR_SIZE(item->objVals, size);\r\n\t\t}\r\n\r\n\t\tchild = &item->objVals[size];\r\n// \t\tif (!(new_item = Json_new())) return 0; /* memory fail */\r\n// \t\tchild->next = new_item;\r\n// \t\tnew_item->prev = child;\r\n// \t\tchild = new_item;\r\n\t\tvalue = skip(parse_string(&strTmp, skip(value + 1)));\r\n\t\tif (!value) return 0;\r\n\t\tchild->name = strTmp.strVal;\r\n\t\tif (*value != ':') {\r\n\t\t\tep = value;\r\n\t\t\treturn 0;\r\n\t\t} /* fail! */\r\n\t\tvalue = skip(parse_value(&child->val, skip(value + 1))); /* skip any spacing, get the value. */\r\n\t\tif (!value) return 0;\r\n\t\tsize++;\r\n\t\tEJSET_ARR_SIZE(item->objVals, size);\r\n//\t\titem->size++;\r\n\t}\r\n\r\n\tif (*value == '}') return value + 1; /* end of array */\r\n\tep = value;\r\n\treturn 0; /* malformed. */\r\n}\r\n\r\nJson *Json_getItem (Json *object, const char* string) {\r\n\tJsonObjEntry* entry = Json_getItemEntry(object, string);\r\n\tif (entry != NULL){\r\n\t\treturn &entry->val;\r\n\t}\r\n\treturn NULL;;\r\n}\r\n\r\nJsonObjEntry *Json_getItemEntry(Json *object, const char* string) {\r\n\tJsonObjEntry* c = NULL;\r\n\tint size =  0;\r\n\tint i = 0;\r\n\tif (object == NULL || object->objVals == NULL){\r\n\t\treturn NULL;\r\n\t}\r\n\tsize =  EJGET_ARR_SIZE(object->objVals);\r\n\tfor(i = 0; i < size; i++){\r\n\t\tif (Json_strcasecmp(object->objVals[i].name, string) == 0){\r\n\t\t\tc = &object->objVals[i];\r\n\t\t}\r\n\t\t//if \r\n\t}\r\n\treturn c;\r\n}\r\n\r\nconst char* Json_getString (Json* object, const char* name, const char* defaultValue) {\r\n\tJsonObjEntry* jsonObj = Json_getItemEntry(object, name);\r\n\tif (jsonObj) return jsonObj->val.strVal;\r\n\treturn defaultValue;\r\n}\r\n\r\nfloat Json_getFloat (Json* value, const char* name, float defaultValue) {\r\n\tJsonObjEntry* jsonObj = Json_getItemEntry(value, name);\r\n\treturn jsonObj ? jsonObj->val.numberVal : defaultValue;\r\n}\r\n\r\nint Json_getInt (Json* value, const char* name, int defaultValue) {\r\n\tJsonObjEntry* jsonObj = Json_getItemEntry(value, name);\r\n\treturn jsonObj ? jsonObj->val.boolVal : defaultValue;\r\n}\r\n\r\nint Json_getCount(Json* data){\r\n\tif (data == NULL){\r\n\t\treturn 0;\r\n\t}\r\n\telse if(data->type == Json_Array){\r\n\t\treturn EJGET_ARR_SIZE(data->arrVals);\r\n\t}\r\n\telse if(data->type == Json_Object){\r\n\t\treturn EJGET_ARR_SIZE(data->objVals);\r\n\t}\r\n    return 0;\r\n}\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/EsotericSoftware/spine-runtimes/issues/comments/233325543","html_url":"https://github.com/EsotericSoftware/spine-runtimes/issues/391#issuecomment-233325543","issue_url":"https://api.github.com/repos/EsotericSoftware/spine-runtimes/issues/391","id":233325543,"user":{"login":"badlogic","id":514052,"avatar_url":"https://avatars.githubusercontent.com/u/514052?v=3","gravatar_id":"","url":"https://api.github.com/users/badlogic","html_url":"https://github.com/badlogic","followers_url":"https://api.github.com/users/badlogic/followers","following_url":"https://api.github.com/users/badlogic/following{/other_user}","gists_url":"https://api.github.com/users/badlogic/gists{/gist_id}","starred_url":"https://api.github.com/users/badlogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/badlogic/subscriptions","organizations_url":"https://api.github.com/users/badlogic/orgs","repos_url":"https://api.github.com/users/badlogic/repos","events_url":"https://api.github.com/users/badlogic/events{/privacy}","received_events_url":"https://api.github.com/users/badlogic/received_events","type":"User","site_admin":false},"created_at":"2016-07-18T13:18:37Z","updated_at":"2016-07-18T13:18:37Z","body":"Please report this to the upstream repository."}}
{"actor":{"display_login":"badlogic"}}