diff options
author | Robert Moore <Robert.Moore@intel.com> | 2014-08-13 13:03:09 -0700 |
---|---|---|
committer | Robert Moore <Robert.Moore@intel.com> | 2014-08-13 13:03:09 -0700 |
commit | f1596580344531d9ae7e68e3f6a20135f9afd976 (patch) | |
tree | 71af75f526c3a02e4701548a48a84df4cfaf829d /source/compiler/aslutils.c | |
parent | aa56682eb125c47565b62f887dc046304f738754 (diff) | |
download | acpica-f1596580344531d9ae7e68e3f6a20135f9afd976.tar.gz |
iASL: Improve cacheing, reduce memory leaks.
Ensure that the parse tree is deleted for each compile.
Fix other miscellaneous memory leaks per-compile.
Consistently deploy the use of the string cache.
Add tracking for multiple buffers within caches.
Ensure the cache buffers are always deleted.
Diffstat (limited to 'source/compiler/aslutils.c')
-rw-r--r-- | source/compiler/aslutils.c | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 5a024705b..f60c8352d 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -626,7 +626,7 @@ UtCheckIntegerRange ( /******************************************************************************* * - * FUNCTION: UtGetStringBuffer + * FUNCTION: UtStringCacheCalloc * * PARAMETERS: Length - Size of buffer requested * @@ -639,22 +639,34 @@ UtCheckIntegerRange ( ******************************************************************************/ char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length) { char *Buffer; + ASL_CACHE_INFO *Cache; if ((Gbl_StringCacheNext + Length) >= Gbl_StringCacheLast) { - Gbl_StringCacheNext = UtLocalCalloc (ASL_STRING_CACHE_SIZE + Length); - Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE + - Length; + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (ASL_STRING_CACHE_SIZE + + sizeof (Cache->Next) + Length); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_StringCacheList; + Gbl_StringCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_StringCacheNext = Cache->Buffer; + Gbl_StringCacheLast = Gbl_StringCacheNext + + (ASL_STRING_CACHE_SIZE + Length); } Buffer = Gbl_StringCacheNext; Gbl_StringCacheNext += Length; - return (Buffer); } @@ -732,6 +744,30 @@ ErrorExit: } +/****************************************************************************** + * + * FUNCTION: UtFreeLineBuffers + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free all line buffers + * + *****************************************************************************/ + +void +UtFreeLineBuffers ( + void) +{ + + free (Gbl_CurrentLineBuffer); + free (Gbl_MainTokenBuffer); + free (Gbl_MacroTokenBuffer); + free (Gbl_ExpressionTokenBuffer); +} + + /******************************************************************************* * * FUNCTION: UtInternalizeName @@ -764,9 +800,9 @@ UtInternalizeName ( Info.ExternalName = ExternalName; AcpiNsGetInternalNameLength (&Info); - /* We need a segment to store the internal name */ + /* We need a segment to store the internal name */ - Info.InternalName = UtGetStringBuffer (Info.Length); + Info.InternalName = UtStringCacheCalloc (Info.Length); if (!Info.InternalName) { return (AE_NO_MEMORY); |