From 6a6425952747cc5716531a9fa0320afca95a6950 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 3 Jul 2021 20:16:49 +0300 Subject: [PATCH] string: bring back the is_lit comment --- vlib/builtin/string.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 108394545d..e12cca7ddd 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -45,6 +45,12 @@ pub struct string { pub: str &byte = 0 // points to a C style 0 terminated string of bytes. len int // the length of the .str field, excluding the ending 0 byte. It is always equal to strlen(.str). + // NB string.is_lit is an enumeration of the following: + // .is_lit == 0 => a fresh string, should be freed by autofree + // .is_lit == 1 => a literal string from .rodata, should NOT be freed + // .is_lit == -98761234 => already freed string, protects against double frees. + // ---------> ^^^^^^^^^ calling free on these is a bug. + // Any other value means that the string has been corrupted. mut: is_lit int }