s.all(length [flags] [fillchar])
s.all(-1)
s.all
s - str variable.
length - number of bytes to allocate, not including the terminating null character.
1 | Preserve previous string (max length bytes). |
2 | Set string length (len property) to length. If this flag not used, len will be 0 or length of preserved string. |
fillchar - character to fill allocated string (except preserved part). If omitted, allocated string content is undefined. In Unicode mode fillchar must be an ASCII character.
Allocates string buffer (memory).
Sets nc property to the number of allocated bytes, not including the terminating null character.
For better performance, may allocate more than length bytes.
Compacts string buffer. It frees extra memory that may be added or not freed by other string functions. Extra memory is used to avoid frequent reallocations.
Frees string buffer. Sets lpstr, len and length properties to 0.
See also: str.fix.
Function all can be used to allocate buffer before calling a dll function that requires pointer to buffer. When dll function returns, use function fix without length or with length = dll function's return value.
int hwnd = win() str s s.all(256) int i = GetWindowText(hwnd s 256) s.fix(i) or: str s.fix(GetWindowText(win() s.all(256) 256))