diff options
author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-05-20 15:40:17 (GMT) |
---|---|---|
committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-05-20 15:40:17 (GMT) |
commit | 96d441c29a2a47269655285a02c546765c163fd2 (patch) | |
tree | 6906aa04fcb87740b514d40f1b4c83435a53a645 /generic/tclInt.h | |
parent | 1b8701ee3d55320b42676e77ce32c04950facee6 (diff) | |
download | tcl-96d441c29a2a47269655285a02c546765c163fd2.zip tcl-96d441c29a2a47269655285a02c546765c163fd2.tar.gz tcl-96d441c29a2a47269655285a02c546765c163fd2.tar.bz2 |
Minor refactor to combine alloc/realloc
Diffstat (limited to 'generic/tclInt.h')
-rw-r--r-- | generic/tclInt.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index f2123b5..bf42f6a 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2909,23 +2909,34 @@ static inline Tcl_Size TclUpsizeRetry(Tcl_Size needed, Tcl_Size lastAttempt) { } MODULE_SCOPE void *TclAllocElemsEx(Tcl_Size elemCount, Tcl_Size elemSize, Tcl_Size leadSize, Tcl_Size *capacityPtr); -MODULE_SCOPE void *TclAttemptAllocElemsEx(Tcl_Size elemCount, Tcl_Size elemSize, - Tcl_Size leadSize, Tcl_Size *capacityPtr); MODULE_SCOPE void *TclReallocElemsEx(void *oldPtr, Tcl_Size elemCount, Tcl_Size elemSize, Tcl_Size leadSize, Tcl_Size *capacityPtr); MODULE_SCOPE void *TclAttemptReallocElemsEx(void *oldPtr, Tcl_Size elemCount, Tcl_Size elemSize, Tcl_Size leadSize, Tcl_Size *capacityPtr); +/* Alloc elemCount elements of size elemSize with leadSize header + * returning actual capacity (in elements) in *capacityPtr. */ +static inline void *TclAttemptAllocElemsEx(Tcl_Size elemCount, Tcl_Size elemSize, + Tcl_Size leadSize, Tcl_Size *capacityPtr) { + return TclAttemptReallocElemsEx( + NULL, elemCount, elemSize, leadSize, capacityPtr); +} +/* Alloc numByte bytes, returning actual capacity in *capacityPtr. */ static inline void *TclAllocEx(Tcl_Size numBytes, Tcl_Size *capacityPtr) { return TclAllocElemsEx(numBytes, 1, 0, capacityPtr); } -static inline void *TclAttemptAllocEx(Tcl_Size numBytes, Tcl_Size *capacityPtr) { +/* Alloc numByte bytes, returning actual capacity in *capacityPtr. */ +static inline void * +TclAttemptAllocEx(Tcl_Size numBytes, Tcl_Size *capacityPtr) +{ return TclAttemptAllocElemsEx(numBytes, 1, 0, capacityPtr); } +/* Realloc numByte bytes, returning actual capacity in *capacityPtr. */ static inline void *TclReallocEx(void *oldPtr, Tcl_Size numBytes, Tcl_Size *capacityPtr) { return TclReallocElemsEx(oldPtr, numBytes, 1, 0, capacityPtr); } +/* Realloc numByte bytes, returning actual capacity in *capacityPtr. */ static inline void *TclAttemptReallocEx(void *oldPtr, Tcl_Size numBytes, Tcl_Size *capacityPtr) { return TclAttemptReallocElemsEx(oldPtr, numBytes, 1, 0, capacityPtr); } |