MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / Strs_ensure_tape_layout

Function Strs_ensure_tape_layout

python/stringzilla.c:1858–1871  ·  view source on GitHub ↗

* @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). */

Source from the content-addressed store, hash-verified

1856 * @return 1 on success, 0 on failure (sets Python exception).
1857 */
1858static 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
1873static PyObject *Strs_get_tape(Strs *self, void *closure) {
1874 // Ensure we're in tape layout

Callers 6

Strs_get_tapeFunction · 0.85
Strs_get_tape_addressFunction · 0.85
Strs_get_offsets_addressFunction · 0.85
Strs_get_tape_nbytesFunction · 0.85
Strs_get_offsets_nbytesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…