TIP 721: New function: Tcl_AttemptGetString()

Login
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:

The functions will return NULL on a memory errors.

Implementation

See the attemptgetstring branch.

Copyright

This document has been placed in the public domain.