From a112105294460f178a371ba9116b11c263b29f00 Mon Sep 17 00:00:00 2001 From: dgp Date: Sun, 7 Nov 2021 22:39:40 +0000 Subject: Update and clarify usage of the TclInitStringRep macro. --- generic/tclInt.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index 08445a5..03d005a 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4486,15 +4486,21 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, /* *---------------------------------------------------------------- * Macro used by the Tcl core to set a Tcl_Obj's string representation to a - * copy of the "len" bytes starting at "bytePtr". This code works even if the - * byte array contains NULLs as long as the length is correct. Because "len" - * is referenced multiple times, it should be as simple an expression as - * possible. The ANSI C "prototype" for this macro is: + * copy of the "len" bytes starting at "bytePtr". The value of "len" must + * not be negative. When "len" is 0, then it is acceptable to pass + * "bytePtr" = NULL. When "len" > 0, "bytePtr" must not be NULL, and it + * must point to a location from which "len" bytes may be read. These + * constraints are not checked here. The validity of the bytes copied + * as a value string representation is also not verififed. This macro + * must not be called while "objPtr" is being freed. The caller must use + * this macro properly. Improper use can lead to dangerous results. + * Because "len" is referenced multiple times, take care that it is an + * expression with the same value each use. + * + * The ANSI C "prototype" for this macro is: * * MODULE_SCOPE void TclInitStringRep(Tcl_Obj *objPtr, char *bytePtr, int len); * - * This macro should only be called on an unshared objPtr where - * objPtr->typePtr->freeIntRepProc == NULL *---------------------------------------------------------------- */ -- cgit v0.12