ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.xs
(Generate patch)

Comparing CBOR-XS/XS.xs (file contents):
Revision 1.42 by root, Tue Dec 10 15:31:40 2013 UTC vs.
Revision 1.45 by root, Sun Dec 14 05:48:39 2014 UTC

7#include <stdlib.h> 7#include <stdlib.h>
8#include <stdio.h> 8#include <stdio.h>
9#include <limits.h> 9#include <limits.h>
10#include <float.h> 10#include <float.h>
11 11
12#define ECB_NO_THREADS 1
12#include "ecb.h" 13#include "ecb.h"
13 14
14// compatibility with perl <5.18 15// compatibility with perl <5.18
15#ifndef HvNAMELEN_get 16#ifndef HvNAMELEN_get
16# define HvNAMELEN_get(hv) strlen (HvNAME (hv)) 17# define HvNAMELEN_get(hv) strlen (HvNAME (hv))
323 324
324 ++enc->depth; 325 ++enc->depth;
325 326
326 encode_uint (enc, MAJOR_ARRAY, len + 1); 327 encode_uint (enc, MAJOR_ARRAY, len + 1);
327 328
329 if (SvMAGICAL (av))
328 for (i = 0; i <= len; ++i) 330 for (i = 0; i <= len; ++i)
329 { 331 {
330 SV **svp = av_fetch (av, i, 0); 332 SV **svp = av_fetch (av, i, 0);
331 encode_sv (enc, svp ? *svp : &PL_sv_undef); 333 encode_sv (enc, svp ? *svp : &PL_sv_undef);
332 } 334 }
335 else
336 for (i = 0; i <= len; ++i)
337 encode_sv (enc, AvARRAY (av)[i]);
333 338
334 --enc->depth; 339 --enc->depth;
335} 340}
336 341
337static void 342static void
736{ 741{
737 // for speed reasons, we specialcase single-string 742 // for speed reasons, we specialcase single-string
738 // byte or utf-8 strings as keys, but only when !stringref 743 // byte or utf-8 strings as keys, but only when !stringref
739 744
740 if (ecb_expect_true (!dec->stringref)) 745 if (ecb_expect_true (!dec->stringref))
741 if (ecb_expect_true ((*dec->cur - MAJOR_BYTES) <= LENGTH_EXT8)) 746 if (ecb_expect_true ((U8)(*dec->cur - MAJOR_BYTES) <= LENGTH_EXT8))
742 { 747 {
743 I32 len = decode_uint (dec); 748 I32 len = decode_uint (dec);
744 char *key = (char *)dec->cur; 749 char *key = (char *)dec->cur;
745 750
746 dec->cur += len; 751 dec->cur += len;
747 752
748 hv_store (hv, key, len, decode_sv (dec), 0); 753 hv_store (hv, key, len, decode_sv (dec), 0);
749 754
750 return; 755 return;
751 } 756 }
752 else if (ecb_expect_true ((*dec->cur - MAJOR_TEXT) <= LENGTH_EXT8)) 757 else if (ecb_expect_true ((U8)(*dec->cur - MAJOR_TEXT) <= LENGTH_EXT8))
753 { 758 {
754 I32 len = decode_uint (dec); 759 I32 len = decode_uint (dec);
755 char *key = (char *)dec->cur; 760 char *key = (char *)dec->cur;
756 761
757 dec->cur += len; 762 dec->cur += len;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines