Sha256: 54cf5023b9e03195655e679ebe7bbc15173224af2e561cdfc2315e5773f1de45
Contents?: true
Size: 1.45 KB
Versions: 8
Compression:
Stored size: 1.45 KB
Contents
#include "SlimList.h" #include "SlimUtil.h" #include <stdlib.h> #include <string.h> #define SKIP(a) \ if (*current != (a))\ {\ SlimList_Destroy(list); \ return 0;\ }\ current++; int readLength(char const** readPtr) { int length = atoi(*readPtr); *readPtr += 6; return length; } int ByteLength( int characterLength, char const * current ) { unsigned char const * p; int chars=0; int bytes=0; for( p = (unsigned char const*) current; chars <= characterLength; p++) { bytes++; if( CSlim_IsCharacter(p) == 1 ) chars++; } if( chars > characterLength ) bytes--; return bytes; } SlimList* SlimList_Deserialize(char const* serializedList) { int listLength; SlimList * list = 0; char const * current = 0; if(serializedList == 0 || strlen(serializedList) == 0) return 0; current = serializedList; list = SlimList_Create(); SKIP('[') listLength = readLength(¤t); SKIP(':') while (listLength--) { int characterLength = readLength(¤t); SKIP(':') int byteLength = ByteLength(characterLength, current); SlimList_AddBuffer(list, current, byteLength); current += byteLength; SKIP(':') } SKIP(']') return list; }
Version data entries
8 entries across 8 versions & 1 rubygems