# HG changeset patch
# User Nils Bruin <nbruin@sfu.ca>
# Date 1347728520 25200
# Node ID e44b99d9b334bb14bf4331c2d6e87652e62ea61e
# Parent 700061226df5b343889aa4744f2376d351523dc0
#13447: Consolidate the two refcount systems implemented for libsingular rings
diff --git a/sage/libs/singular/ring.pyx b/sage/libs/singular/ring.pyx
a
|
b
|
cdef ring *singular_ring_new(base_ring, |
323 | 323 | _ring.ShortOut = 0 |
324 | 324 | |
325 | 325 | rChangeCurrRing(_ring) |
326 | | |
327 | | wrapped_ring = wrap_ring(_ring) |
328 | | if wrapped_ring in ring_refcount_dict: |
329 | | raise ValueError('newly created ring already in dictionary??') |
330 | | ring_refcount_dict[wrapped_ring] = 1 |
| 326 | _ring.ref=1 |
331 | 327 | return _ring |
332 | 328 | |
333 | 329 | |
… |
… |
cdef ring *singular_ring_reference(ring |
492 | 488 | """ |
493 | 489 | if existing_ring==NULL: |
494 | 490 | raise ValueError('singular_ring_reference(ring*) called with NULL pointer.') |
495 | | cdef object r = wrap_ring(existing_ring) |
496 | | refcount = ring_refcount_dict.pop(r) |
497 | | ring_refcount_dict[r] = refcount+1 |
| 491 | existing_ring.ref=existing_ring.ref+1 |
498 | 492 | return existing_ring |
499 | 493 | |
500 | 494 | |
… |
… |
cdef void singular_ring_delete(ring *doo |
534 | 528 | if not ring_refcount_dict: # arbitrary finalization order when we shut Sage down |
535 | 529 | return |
536 | 530 | |
537 | | cdef ring_wrapper_Py r = wrap_ring(doomed) |
538 | | refcount = ring_refcount_dict.pop(r) |
539 | | if refcount > 1: |
540 | | ring_refcount_dict[r] = refcount-1 |
| 531 | if doomed.ref > 1: |
| 532 | doomed.ref = doomed.ref-1 |
541 | 533 | return |
542 | 534 | |
543 | 535 | global currRing |