📄 alloc.3
字号:
'\"'\" Copyright (c) 1995-1996 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" RCS: @(#) $Id: Alloc.3,v 1.8 2002/10/09 09:38:38 dkf Exp $'\" .so man.macros.TH Tcl_Alloc 3 7.5 Tcl "Tcl Library Procedures".BS.SH NAMETcl_Alloc, Tcl_Free, Tcl_Realloc, Tcl_AttemptAlloc, Tcl_AttemptRealloc, ckalloc, ckfree, ckrealloc, attemptckalloc, attemptckrealloc \- allocate or free heap memory.SH SYNOPSIS.nf\fB#include <tcl.h>\fR.spchar *\fBTcl_Alloc\fR(\fIsize\fR).spvoid\fBTcl_Free\fR(\fIptr\fR).spchar *\fBTcl_Realloc\fR(\fIptr, size\fR).spchar *\fBTcl_AttemptAlloc\fR(\fIsize\fR).spchar *\fBTcl_AttemptRealloc\fR(\fIptr, size\fR).spchar *\fBckalloc\fR(\fIsize\fR).spvoid\fBckfree\fR(\fIptr\fR).spchar *\fBckrealloc\fR(\fIptr, size\fR).spchar *\fBattemptckalloc\fR(\fIsize\fR).spchar *\fBattemptckrealloc\fR(\fIptr, size\fR).SH ARGUMENTS.AS char *size.AP int size inSize in bytes of the memory block to allocate..AP char *ptr inPointer to memory block to free or realloc..BE.SH DESCRIPTION.PPThese procedures provide a platform and compiler independent interfacefor memory allocation. Programs that need to transfer ownership ofmemory blocks between Tcl and other modules should use these routinesrather than the native \fBmalloc()\fR and \fBfree()\fR routinesprovided by the C run-time library..PP\fBTcl_Alloc\fR returns a pointer to a block of at least \fIsize\fRbytes suitably aligned for any use..PP\fBTcl_Free\fR makes the space referred to by \fIptr\fR available forfurther allocation..PP\fBTcl_Realloc\fR changes the size of the block pointed to by\fIptr\fR to \fIsize\fR bytes and returns a pointer to the new block.The contents will be unchanged up to the lesser of the new and oldsizes. The returned location may be different from \fIptr\fR..PP\fBTcl_AttemptAlloc\fR and \fBTcl_AttemptRealloc\fR are identical infunction to \fBTcl_Alloc\fR and \fBTcl_Realloc\fR, except that\fBTcl_AttemptAlloc\fR and \fBTcl_AttemptRealloc\fR will not cause the Tclinterpreter to \fBpanic\fR if the memory allocation fails. If theallocation fails, these functions will return NULL. Note that on someplatforms, attempting to allocate a block of memory will also causethese functions to return NULL..PPThe procedures \fBckalloc\fR, \fBckfree\fR, \fBckrealloc\fR,\fBattemptckalloc\fR, and \fBattemptckrealloc\fR are implementedas macros. Normally, they are synonyms for the correspondingprocedures documented on this page. When Tcl and all modulescalling Tcl are compiled with \fBTCL_MEM_DEBUG\fR defined, however,these macros are redefined to be special debugging versions of of these procedures. To support Tcl's memory debugging within amodule, use the macros rather than direct calls to \fBTcl_Alloc\fR, etc..SH KEYWORDSalloc, allocation, free, malloc, memory, realloc, TCL_MEM_DEBUG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -