* Steals a reference to the object. */
| 613 | * Steals a reference to the object. |
| 614 | */ |
| 615 | static inline int |
| 616 | npy_new_coercion_cache( |
| 617 | PyObject *converted_obj, PyObject *arr_or_sequence, npy_bool sequence, |
| 618 | coercion_cache_obj ***next_ptr, int ndim) |
| 619 | { |
| 620 | coercion_cache_obj *cache; |
| 621 | if (_coercion_cache_num > 0) { |
| 622 | _coercion_cache_num--; |
| 623 | cache = _coercion_cache_cache[_coercion_cache_num]; |
| 624 | } |
| 625 | else { |
| 626 | cache = PyMem_Malloc(sizeof(coercion_cache_obj)); |
| 627 | } |
| 628 | if (cache == NULL) { |
| 629 | Py_DECREF(arr_or_sequence); |
| 630 | PyErr_NoMemory(); |
| 631 | return -1; |
| 632 | } |
| 633 | cache->converted_obj = converted_obj; |
| 634 | cache->arr_or_sequence = arr_or_sequence; |
| 635 | cache->sequence = sequence; |
| 636 | cache->depth = ndim; |
| 637 | cache->next = NULL; |
| 638 | **next_ptr = cache; |
| 639 | *next_ptr = &(cache->next); |
| 640 | return 0; |
| 641 | } |
| 642 | |
| 643 | /** |
| 644 | * Unlink coercion cache item. |
no outgoing calls
no test coverage detected