From bb278092e0f8c282aa2a8a78e44ccd9208b35ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Fri, 6 Mar 2026 23:01:13 +0100 Subject: [PATCH] memory: move ecl_alloc_adjustable_*_string to memory.d These constructors are used to provide buffers that may be returned to cl_core. --- src/c/memory.d | 35 +++++++++++++++++++++++++++++++++++ src/c/string.d | 35 ----------------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/c/memory.d b/src/c/memory.d index 44dfff39b..005c2abb1 100644 --- a/src/c/memory.d +++ b/src/c/memory.d @@ -149,6 +149,41 @@ ecl_append_unsafe(cl_object x, cl_object y) return head; } +/* + Make a string of a certain size, with some leading zeros to keep C happy. The + string must be adjustable, to allow further growth. (See unixfsys.c for its + use). +*/ +cl_object +ecl_alloc_adjustable_base_string(cl_index l) +{ + cl_object output = ecl_alloc_object(t_base_string); + output->base_string.self = (ecl_base_char *)ecl_alloc_atomic(l+1); + output->base_string.self[l] = 0; + output->base_string.flags = ECL_FLAG_HAS_FILL_POINTER | ECL_FLAG_ADJUSTABLE; + output->base_string.elttype = ecl_aet_bc; + output->base_string.displaced = ECL_NIL; + output->base_string.dim = l; + output->base_string.fillp = 0; + return output; +} + +#ifdef ECL_UNICODE +cl_object +ecl_alloc_adjustable_extended_string(cl_index l) +{ + cl_index bytes = sizeof(ecl_character) * l; + cl_object output = ecl_alloc_object(t_string); + output->string.self = (ecl_character *)ecl_alloc_atomic(bytes); + output->string.flags = ECL_FLAG_HAS_FILL_POINTER | ECL_FLAG_ADJUSTABLE; + output->string.elttype = ecl_aet_ch; + output->string.displaced = ECL_NIL; + output->string.dim = l; + output->string.fillp = 0; + return output; +} +#endif + /* -- Rudimentary manual memory allocator ----------------------------------- */ static cl_object diff --git a/src/c/string.d b/src/c/string.d index e511b4ed7..b04e93d8a 100644 --- a/src/c/string.d +++ b/src/c/string.d @@ -69,41 +69,6 @@ do_make_string(cl_index s, ecl_character code) @(return x); @) -/* - Make a string of a certain size, with some leading zeros to - keep C happy. The string must be adjustable, to allow further - growth. (See unixfsys.c for its use). -*/ -cl_object -ecl_alloc_adjustable_base_string(cl_index l) -{ - cl_object output = ecl_alloc_object(t_base_string); - output->base_string.self = (ecl_base_char *)ecl_alloc_atomic(l+1); - output->base_string.self[l] = 0; - output->base_string.flags = ECL_FLAG_HAS_FILL_POINTER | ECL_FLAG_ADJUSTABLE; - output->base_string.elttype = ecl_aet_bc; - output->base_string.displaced = ECL_NIL; - output->base_string.dim = l; - output->base_string.fillp = 0; - return output; -} - -#ifdef ECL_UNICODE -cl_object -ecl_alloc_adjustable_extended_string(cl_index l) -{ - cl_index bytes = sizeof(ecl_character) * l; - cl_object output = ecl_alloc_object(t_string); - output->string.self = (ecl_character *)ecl_alloc_atomic(bytes); - output->string.flags = ECL_FLAG_HAS_FILL_POINTER | ECL_FLAG_ADJUSTABLE; - output->string.elttype = ecl_aet_ch; - output->string.displaced = ECL_NIL; - output->string.dim = l; - output->string.fillp = 0; - return output; -} -#endif - /* ecl_make_simple_base_string(s) creates a simple-base string from C string s. ecl_make_constant_base_string(s) does the same, but without copying the C string.