Author: Jan Nijtmans <[email protected]>
State: Draft
Type: Project
Tcl-Version: 9.1
Tcl-Branch: attemptgetstring
Abstract
This TIP proposes new functions Tcl_AttemptGetString() and Tcl_AttemptGetStringFromObj(). They do almost the same as Tcl_GetString()/Tcl_GetStringFromObj, only in case of failing memory allocation they return NULL in stead of panicing.
Rationale
The new functions allow to handle memory exhaustion better than the old functions do.
The main place this new function will be used is in handling lists and dictionaries. When they become huge, causing memory exhaustion, it's better to clear its contents and give an error-message than panicing.
Specification
Declare and implement new functions:
char *Tcl_AttemptGetString(Tcl_Obj *objPtr)
char *Tcl_AttemptGetStringFromObj(Tcl_Obj *objPtr, Tcl_Size *lengthPtr)
The functions will return NULL on a memory errors.
Implementation
See the attemptgetstring branch.
Copyright
This document has been placed in the public domain.