--- JSON-XS/XS.xs 2008/03/26 02:35:45 1.82 +++ JSON-XS/XS.xs 2008/03/26 22:54:38 1.83 @@ -104,6 +104,17 @@ ///////////////////////////////////////////////////////////////////////////// // utility functions +INLINE SV * +get_bool (const char *name) +{ + SV *sv = get_sv (name, 1); + + SvREADONLY_on (sv); + SvREADONLY_on (SvRV (sv)); + + return sv; +} + INLINE void shrink (SV *sv) { @@ -1345,9 +1356,9 @@ { dec->cur += 4; #if JSON_SLOW - json_true = get_sv ("JSON::XS::true", 1); SvREADONLY_on (json_true); + json_true = get_bool ("JSON::XS::true"); #endif - return SvREFCNT_inc (json_true); + return newSVsv (json_true); } else ERR ("'true' expected"); @@ -1359,9 +1370,9 @@ { dec->cur += 5; #if JSON_SLOW - json_false = get_sv ("JSON::XS::false", 1); SvREADONLY_on (json_false); + json_false = get_bool ("JSON::XS::false"); #endif - return SvREFCNT_inc (json_false); + return newSVsv (json_false); } else ERR ("'false' expected"); @@ -1609,8 +1620,8 @@ json_stash = gv_stashpv ("JSON::XS" , 1); json_boolean_stash = gv_stashpv ("JSON::XS::Boolean", 1); - json_true = get_sv ("JSON::XS::true" , 1); SvREADONLY_on (json_true ); - json_false = get_sv ("JSON::XS::false", 1); SvREADONLY_on (json_false); + json_true = get_bool ("JSON::XS::true"); + json_false = get_bool ("JSON::XS::false"); } PROTOTYPES: DISABLE