… | |
… | |
112 | } |
112 | } |
113 | |
113 | |
114 | static SV * |
114 | static SV * |
115 | newSVptr (void *ptr, const char *klass) |
115 | newSVptr (void *ptr, const char *klass) |
116 | { |
116 | { |
|
|
117 | SV *sv; |
|
|
118 | |
117 | if (!ptr) |
119 | if (!ptr) |
118 | return &PL_sv_undef; |
120 | return &PL_sv_undef; |
119 | |
121 | |
120 | HV *hv = newHV (); |
122 | sv = newSV (0); |
121 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
123 | sv_magic (sv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
122 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
124 | return sv_bless (newRV_noinc (sv), gv_stashpv (klass, 1)); |
123 | } |
125 | } |
124 | |
126 | |
125 | static SV * |
127 | static SV * |
126 | newSVptr_cached (void *ptr, const char *klass) |
128 | newSVptr_cached (void *ptr, const char *klass) |
127 | { |
129 | { |
… | |
… | |
134 | |
136 | |
135 | if (he) |
137 | if (he) |
136 | sv = *he; |
138 | sv = *he; |
137 | else |
139 | else |
138 | { |
140 | { |
139 | sv = newSVptr (ptr, klass); |
141 | HV *hv = newHV (); |
|
|
142 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
|
|
143 | sv = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
140 | hv_store (obj_cache, (char *)&ptr, sizeof (ptr), sv, 0); |
144 | hv_store (obj_cache, (char *)&ptr, sizeof (ptr), sv, 0); |
141 | } |
145 | } |
142 | |
146 | |
143 | return newSVsv (sv); |
147 | return newSVsv (sv); |
144 | } |
148 | } |
… | |
… | |
522 | |
526 | |
523 | va_end (args); |
527 | va_end (args); |
524 | |
528 | |
525 | if (context.event_code == EVENT_FREE_OB) |
529 | if (context.event_code == EVENT_FREE_OB) |
526 | { |
530 | { |
527 | SV **svp = hv_fetch (obj_cache, (char *)&context.activator, sizeof (void *), 0); |
531 | SV *sv = hv_delete (obj_cache, (char *)&context.activator, sizeof (void *), 0); |
528 | |
532 | |
529 | if (svp) |
533 | if (sv) |
530 | clearSVptr (*svp); |
534 | clearSVptr (sv); |
531 | } |
535 | } |
532 | else |
536 | else |
533 | inject_event ("cf::inject_global_event", &context); |
537 | inject_event ("cf::inject_global_event", &context); |
534 | |
538 | |
535 | rv = context.returnvalue; |
539 | rv = context.returnvalue; |