A string, both in Common-Lisp and in ECL is nothing but a vector of
characters. Therefore, almost everything mentioned in the section of arrays
remains valid here. The only important difference is that ECL stores
strings as a lisp object with a pointer to a zero terminated C string. Thus, if
a string has n
characters, ECL will reserve n
+1 bytes for the
string. This allows us to pass the string self
pointer to any C
routine.
If x
is a lisp object of type string, we can access the following fields:
| Maximum number of characters that it can contain. |
| Actual number of characters in the string. |
| Pointer to the characters. |
| True if |
— Function: cl_objectmake_simple_string
(char*
s
)— Function: cl_objectmake_string_copy
(char*
s
)Both routines build a lisp string from a C string.
make_string_copy
allocates new space and copies the content of the string to it.make_simple_string
simply uses the memory pointed bys
, which should not be deallocated. Both routines usestrlen
to calculate the length of the string.