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

Comparing JSON-XS/XS.xs (file contents):
Revision 1.92 by root, Mon Sep 22 07:29:29 2008 UTC vs.
Revision 1.95 by root, Sun Feb 22 06:55:28 2009 UTC

194INLINE void 194INLINE void
195need (enc_t *enc, STRLEN len) 195need (enc_t *enc, STRLEN len)
196{ 196{
197 if (expect_false (enc->cur + len >= enc->end)) 197 if (expect_false (enc->cur + len >= enc->end))
198 { 198 {
199 STRLEN cur = enc->cur - SvPVX (enc->sv); 199 STRLEN cur = enc->cur - (char *)SvPVX (enc->sv);
200 SvGROW (enc->sv, cur + len + 1); 200 SvGROW (enc->sv, cur + (len < (cur >> 2) ? cur >> 2 : len) + 1);
201 enc->cur = SvPVX (enc->sv) + cur; 201 enc->cur = SvPVX (enc->sv) + cur;
202 enc->end = SvPVX (enc->sv) + SvLEN (enc->sv) - 1; 202 enc->end = SvPVX (enc->sv) + SvLEN (enc->sv) - 1;
203 } 203 }
204} 204}
205 205
970 { 970 {
971 STRLEN len = cur - buf; 971 STRLEN len = cur - buf;
972 972
973 if (sv) 973 if (sv)
974 { 974 {
975 SvGROW (sv, SvCUR (sv) + len + 1); 975 STRLEN cur = SvCUR (sv);
976
977 if (SvLEN (sv) <= cur + len)
978 SvGROW (sv, cur + (len < (cur >> 2) ? cur >> 2 : len) + 1);
979
976 memcpy (SvPVX (sv) + SvCUR (sv), buf, len); 980 memcpy (SvPVX (sv) + SvCUR (sv), buf, len);
977 SvCUR_set (sv, SvCUR (sv) + len); 981 SvCUR_set (sv, SvCUR (sv) + len);
978 } 982 }
979 else 983 else
980 sv = newSVpvn (buf, len); 984 sv = newSVpvn (buf, len);
1410{ 1414{
1411 dec_t dec; 1415 dec_t dec;
1412 STRLEN offset; 1416 STRLEN offset;
1413 SV *sv; 1417 SV *sv;
1414 1418
1419 /* work around bugs in 5.10 where manipulating magic values
1420 * will perl ignore the magic in subsequent accesses
1421 */
1415 SvGETMAGIC (string); 1422 /*SvGETMAGIC (string);*/
1423 if (SvMAGICAL (string))
1424 string = sv_2mortal (newSVsv (string));
1425
1416 SvUPGRADE (string, SVt_PV); 1426 SvUPGRADE (string, SVt_PV);
1417 1427
1418 /* work around a bug in perl 5.10, which causes SvCUR to fail an 1428 /* work around a bug in perl 5.10, which causes SvCUR to fail an
1419 * assertion with -DDEBUGGING, although SvCUR is documented to 1429 * assertion with -DDEBUGGING, although SvCUR is documented to
1420 * return the xpv_cur field which certainly exists after upgrading. 1430 * return the xpv_cur field which certainly exists after upgrading.
1799 } 1809 }
1800 1810
1801 { 1811 {
1802 STRLEN len; 1812 STRLEN len;
1803 const char *str = SvPV (jsonstr, len); 1813 const char *str = SvPV (jsonstr, len);
1804 SvGROW (self->incr_text, SvCUR (self->incr_text) + len + 1); 1814 STRLEN cur = SvCUR (self->incr_text);
1815
1816 if (SvLEN (self->incr_text) <= cur + len)
1817 SvGROW (self->incr_text, cur + (len < (cur >> 2) ? cur >> 2 : len) + 1);
1818
1805 Move (str, SvEND (self->incr_text), len, char); 1819 Move (str, SvEND (self->incr_text), len, char);
1806 SvCUR_set (self->incr_text, SvCUR (self->incr_text) + len); 1820 SvCUR_set (self->incr_text, SvCUR (self->incr_text) + len);
1807 *SvEND (self->incr_text) = 0; // this should basically be a nop, too, but make sure it's there 1821 *SvEND (self->incr_text) = 0; // this should basically be a nop, too, but make sure it's there
1808 } 1822 }
1809 } 1823 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines