This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove two use of dXSI32; superfluous because xsubpp automatically adds it.
[perl5.git] / ext / Hash-Util / Util.xs
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4
5 MODULE = Hash::Util             PACKAGE = Hash::Util
6
7 void
8 all_keys(hash,keys,placeholder)
9         HV *hash
10         AV *keys
11         AV *placeholder
12     PROTOTYPE: \%\@\@
13     PREINIT:
14         SV *key;
15         HE *he;
16     PPCODE:
17         av_clear(keys);
18         av_clear(placeholder);
19
20         (void)hv_iterinit(hash);
21         while((he = hv_iternext_flags(hash, HV_ITERNEXT_WANTPLACEHOLDERS))!= NULL) {
22             key=hv_iterkeysv(he);
23             av_push(HeVAL(he) == &PL_sv_placeholder ? placeholder : keys,
24                     SvREFCNT_inc(key));
25         }
26         XSRETURN(1);
27
28 void
29 hidden_ref_keys(hash)
30         HV *hash
31     ALIAS:
32         Hash::Util::legal_ref_keys = 1
33     PREINIT:
34         SV *key;
35         HE *he;
36     PPCODE:
37         (void)hv_iterinit(hash);
38         while((he = hv_iternext_flags(hash, HV_ITERNEXT_WANTPLACEHOLDERS))!= NULL) {
39             key=hv_iterkeysv(he);
40             if (ix || HeVAL(he) == &PL_sv_placeholder) {
41                 XPUSHs( key );
42             }
43         }
44
45 void
46 hv_store(hash, key, val)
47         HV *hash
48         SV* key
49         SV* val
50     PROTOTYPE: \%$$
51     CODE:
52     {
53         SvREFCNT_inc(val);
54         if (!hv_store_ent(hash, key, val, 0)) {
55             SvREFCNT_dec(val);
56             XSRETURN_NO;
57         } else {
58             XSRETURN_YES;
59         }
60     }