* @brief Ensures the Strs is in a tape layout (not fragmented). * Converts FRAGMENTED to TAPE if necessary. * @return 1 on success, 0 on failure (sets Python exception). */
| 1856 | * @return 1 on success, 0 on failure (sets Python exception). |
| 1857 | */ |
| 1858 | static int Strs_ensure_tape_layout(Strs *self) { |
| 1859 | if (self->layout != STRS_FRAGMENTED) return 1; // Already in tape layout |
| 1860 | |
| 1861 | // Get the default allocator |
| 1862 | sz_memory_allocator_t allocator; |
| 1863 | sz_memory_allocator_init_default(&allocator); |
| 1864 | |
| 1865 | // Convert fragmented to tape |
| 1866 | if (!sz_py_replace_fragmented_allocator(self, &self->data.fragmented.allocator, &allocator)) { |
| 1867 | PyErr_SetString(PyExc_MemoryError, "Failed to convert fragmented layout to tape"); |
| 1868 | return 0; |
| 1869 | } |
| 1870 | return 1; |
| 1871 | } |
| 1872 | |
| 1873 | static PyObject *Strs_get_tape(Strs *self, void *closure) { |
| 1874 | // Ensure we're in tape layout |
no test coverage detected
searching dependent graphs…