Alloc.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
- '"
- '" 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 NAME
- Tcl_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
- .sp
- char *
- fBTcl_AllocfR(fIsizefR)
- .sp
- void
- fBTcl_FreefR(fIptrfR)
- .sp
- char *
- fBTcl_ReallocfR(fIptr, sizefR)
- .sp
- char *
- fBTcl_AttemptAllocfR(fIsizefR)
- .sp
- char *
- fBTcl_AttemptReallocfR(fIptr, sizefR)
- .sp
- char *
- fBckallocfR(fIsizefR)
- .sp
- void
- fBckfreefR(fIptrfR)
- .sp
- char *
- fBckreallocfR(fIptr, sizefR)
- .sp
- char *
- fBattemptckallocfR(fIsizefR)
- .sp
- char *
- fBattemptckreallocfR(fIptr, sizefR)
- .SH ARGUMENTS
- .AS char *size
- .AP int size in
- Size in bytes of the memory block to allocate.
- .AP char *ptr in
- Pointer to memory block to free or realloc.
- .BE
- .SH DESCRIPTION
- .PP
- These procedures provide a platform and compiler independent interface
- for memory allocation. Programs that need to transfer ownership of
- memory blocks between Tcl and other modules should use these routines
- rather than the native fBmalloc()fR and fBfree()fR routines
- provided by the C run-time library.
- .PP
- fBTcl_AllocfR returns a pointer to a block of at least fIsizefR
- bytes suitably aligned for any use.
- .PP
- fBTcl_FreefR makes the space referred to by fIptrfR available for
- further allocation.
- .PP
- fBTcl_ReallocfR changes the size of the block pointed to by
- fIptrfR to fIsizefR bytes and returns a pointer to the new block.
- The contents will be unchanged up to the lesser of the new and old
- sizes. The returned location may be different from fIptrfR.
- .PP
- fBTcl_AttemptAllocfR and fBTcl_AttemptReallocfR are identical in
- function to fBTcl_AllocfR and fBTcl_ReallocfR, except that
- fBTcl_AttemptAllocfR and fBTcl_AttemptReallocfR will not cause the Tcl
- interpreter to fBpanicfR if the memory allocation fails. If the
- allocation fails, these functions will return NULL. Note that on some
- platforms, attempting to allocate a block of memory will also cause
- these functions to return NULL.
- .PP
- The procedures fBckallocfR, fBckfreefR, fBckreallocfR,
- fBattemptckallocfR, and fBattemptckreallocfR are implemented
- as macros. Normally, they are synonyms for the corresponding
- procedures documented on this page. When Tcl and all modules
- calling Tcl are compiled with fBTCL_MEM_DEBUGfR defined, however,
- these macros are redefined to be special debugging versions of
- of these procedures. To support Tcl's memory debugging within a
- module, use the macros rather than direct calls to fBTcl_AllocfR, etc.
- .SH KEYWORDS
- alloc, allocation, free, malloc, memory, realloc, TCL_MEM_DEBUG