Ticket #1351: bignum.pmc.patch
File bignum.pmc.patch, 1.9 KB (added by jimmy, 12 years ago) |
---|
-
src/pmc/bignum.pmc
153 153 154 154 static void 155 155 bignum_init(PARROT_INTERP, PMC *self) { 156 Parrot_BigNum_attributes *attrs =157 mem_allocate_zeroed_typed(Parrot_BigNum_attributes);158 156 #ifdef PARROT_HAS_GMP 159 attrs->bn = mem_allocate_zeroed_typed(BIGNUM); 160 mpf_clear(attrs->bn->b); 161 mpf_init(attrs->bn->b); 157 BIGNUM * const bn = mem_allocate_zeroed_typed(BIGNUM); 158 SETATTR_BigNum_bn(interp, self, bn); 159 mpf_clear(bn->b); 160 mpf_init(bn->b); 162 161 #else 163 attrs->bn = NULL;162 SETATTR_BigNum_bn(interp, SELF, NULL); 164 163 #endif 165 PMC_data(self) = attrs;166 164 } 167 165 168 166 … … 173 171 GETATTR_BigNum_bn(interp, self, bn); 174 172 mpf_clear(bn->b); 175 173 #endif 174 mem_sys_free(bn); 176 175 } 177 176 178 177 … … 225 224 static void 226 225 bignum_set_bigint(PARROT_INTERP, PMC *self, struct BIGINT *value) { 227 226 BIGNUM *bn; 228 struct BIGINT *bi;229 227 GETATTR_BigNum_bn(interp, self, bn); 230 bi->b = PARROT_BIGINT(value); 231 mpf_set(bn->b, (mpf_srcptr)bi->b); 228 mpf_set(bn->b, (mpf_srcptr)value->b); 232 229 } 233 230 # endif 234 231 … … 243 240 bignum_set_self(PARROT_INTERP, PMC *self, BIGNUM *value) { 244 241 BIGNUM *bn; 245 242 GETATTR_BigNum_bn(interp, self, bn); 246 mpf_set(bn->b, (mpf_srcptr)( (BIGNUM*)value)->b);243 mpf_set(bn->b, (mpf_srcptr)(value)->b); 247 244 } 248 245 249 246 static long … … 778 775 779 776 #endif /* ifdef PARROT_HAS_GMP */ 780 777 781 pmclass BigNum {778 pmclass BigNum auto_attrs { 782 779 ATTR struct BIGNUM * bn; /*bignum val*/ 783 780 784 781 /* … … 819 816 } 820 817 821 818 VTABLE void destroy() { 822 BIGNUM *bn;823 Parrot_BigNum_attributes *attrs;824 825 819 bignum_clear(INTERP, SELF); 826 827 attrs = (Parrot_BigNum_attributes*)PMC_data(SELF);828 #ifdef PARROT_HAS_GMP829 mem_sys_free(attrs->bn);830 #endif831 mem_sys_free(attrs);832 PMC_data(SELF) = NULL;833 820 } 834 821 835 822 /*