yury 
							
						 
					 
					
						
						
						
						
							
						
						
							9d41a435c2 
							
						 
					 
					
						
						
							
							* tinyheap: Disable inline when FPC_TINYHEAP_HUGE is defined to prevent code bloat.  
						
						... 
						
						
						
						git-svn-id: trunk@46492 - 
						
					 
					
						2020-08-19 10:48:00 +00:00 
						 
				 
			
				
					
						
							
							
								yury 
							
						 
					 
					
						
						
						
						
							
						
						
							6edbc9ed7e 
							
						 
					 
					
						
						
							
							* tinyheap: Early check for very big requested mem sizes in order to prevent overflows and properly report the out of memory error.  
						
						... 
						
						
						
						git-svn-id: trunk@45844 - 
						
					 
					
						2020-07-24 16:02:13 +00:00 
						 
				 
			
				
					
						
							
							
								pierre 
							
						 
					 
					
						
						
						
						
							
						
						
							a16326fa95 
							
						 
					 
					
						
						
							
							Avoid MSDOS Memory Control Block (MCB) chain corruption in RegisterTinyHeapBlock  
						
						... 
						
						
						
						git-svn-id: trunk@36340 - 
						
					 
					
						2017-05-26 06:44:07 +00:00 
						 
				 
			
				
					
						
							
							
								pierre 
							
						 
					 
					
						
						
						
						
							
						
						
							0f80603dae 
							
						 
					 
					
						
						
							
							+ SysGetMem: Add DEBUG_TINY_HEAP message after SysAlloc call.  
						
						... 
						
						
						
						* Change InternalTinyAlign procedure:
  Change variable ASize to be VAR parameter type
  so that possible size reduction required by alignment
  is propagated correctly to calling function.
git-svn-id: trunk@36297 - 
						
					 
					
						2017-05-22 20:27:08 +00:00 
						 
				 
			
				
					
						
							
							
								pierre 
							
						 
					 
					
						
						
						
						
							
						
						
							ade39069e5 
							
						 
					 
					
						
						
							
							Change ASize type for RegisterTinyHeapBlockXXX functions  
						
						... 
						
						
						
						git-svn-id: trunk@36249 - 
						
					 
					
						2017-05-18 22:36:24 +00:00 
						 
				 
			
				
					
						
							
							
								pierre 
							
						 
					 
					
						
						
						
						
							
						
						
							570f159e65 
							
						 
					 
					
						
						
							
							Get SysGetMem to return immediately with Result=Nil if SysOSAlloc fails and RetrunNilIfGrowHeapFails is true  
						
						... 
						
						
						
						git-svn-id: trunk@36239 - 
						
					 
					
						2017-05-18 08:19:17 +00:00 
						 
				 
			
				
					
						
							
							
								pierre 
							
						 
					 
					
						
						
						
						
							
						
						
							a72434e93a 
							
						 
					 
					
						
						
							
							Trial to clarify heap for i8086 issues:  
						
						... 
						
						
						
						- MSDOS heap in tinyheap.inc modified to use usual
  SysGetMem and similar names.
  - Use HAS_MEMORYMANAGER (used previously in wince source code,
  to specify that a memory manager is defined elsewhere than inside
  heap.inc include file.
  - Use
  - Remove TinyHeapMemoryManager Structure variable completely
  heaptrc.pp: remove unneeded macro code after name changes of tinyheap.inc
  msdos/system.pp now only defines HAS_MEMORYMANAGER macro
  win16/system.pp defines HAS_MEMORYMANAGER and FPC_NO_DEFAULT_HEAP
  as it still uses a different memory manager.
  __stkbottom variable added for win16 system.pp as it is required
  by i8086 specific stack check code.
git-svn-id: trunk@33983 - 
						
					 
					
						2016-06-13 22:26:03 +00:00 
						 
				 
			
				
					
						
							
							
								pierre 
							
						 
					 
					
						
						
						
						
							
						
						
							91595447c6 
							
						 
					 
					
						
						
							
							Add SysTinyGetHeapStatus and SysTinyGetFPCHeapStatus functions  
						
						... 
						
						
						
						git-svn-id: trunk@33681 - 
						
					 
					
						2016-05-11 14:37:38 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							d8a9860e92 
							
						 
					 
					
						
						
							
							+ optimization in tinyheap's reallocmem for the case when there's not enough  
						
						... 
						
						
						
						space after the block, but it becomes enough when the space before the block
  is also reclaimed
git-svn-id: trunk@28786 - 
						
					 
					
						2014-10-07 14:36:23 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							1e0a69fa7f 
							
						 
					 
					
						
						
							
							+ optimizations in SysTinyReAllocMem for the case when growing the heap block  
						
						... 
						
						
						
						and there is enough free space after the block
git-svn-id: trunk@28723 - 
						
					 
					
						2014-09-29 09:48:45 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							e9dc9735a0 
							
						 
					 
					
						
						
							
							+ check whether the pointer passed to SysTinyReAllocMem is within the heap area  
						
						... 
						
						
						
						(the same check used as in SysTinyFreeMem)
git-svn-id: trunk@28721 - 
						
					 
					
						2014-09-28 15:27:44 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							e4f3f33692 
							
						 
					 
					
						
						
							
							+ optimization in SysTinyReAllocMem for the case of shrinking a memory block  
						
						... 
						
						
						
						git-svn-id: trunk@28714 - 
						
					 
					
						2014-09-23 01:29:53 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							782b033acd 
							
						 
					 
					
						
						
							
							* optimized SysTinyReAllocMem for the case when the new and old size are the  
						
						... 
						
						
						
						same after alignment to TinyHeapAllocGranularity
git-svn-id: trunk@28706 - 
						
					 
					
						2014-09-22 12:48:12 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							4e48190342 
							
						 
					 
					
						
						
							
							+ implemented Mark and Release for the tiny heap  
						
						... 
						
						
						
						git-svn-id: trunk@28700 - 
						
					 
					
						2014-09-20 23:33:54 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							6735e717ef 
							
						 
					 
					
						
						
							
							* the results of MemAvail and MaxAvail changed to LongInt in the i8086 far data  
						
						... 
						
						
						
						memory models (TP7 compatibility)
git-svn-id: trunk@28667 - 
						
					 
					
						2014-09-14 21:11:32 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							00c98edd29 
							
						 
					 
					
						
						
							
							* the FPC_TINYHEAP_HUGE define moved to tnyheaph.inc  
						
						... 
						
						
						
						git-svn-id: trunk@28666 - 
						
					 
					
						2014-09-14 20:42:35 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							706a1d8712 
							
						 
					 
					
						
						
							
							* the FPC_HEAP_HUGE define renamed FPC_TINYHEAP_HUGE, because it applies to the  
						
						... 
						
						
						
						tiny heap, not the regular one
git-svn-id: trunk@28665 - 
						
					 
					
						2014-09-14 20:10:48 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							624b3204d8 
							
						 
					 
					
						
						
							
							+ added and implemented MemAvail and MaxAvail for the tiny heap  
						
						... 
						
						
						
						git-svn-id: trunk@28664 - 
						
					 
					
						2014-09-14 18:35:15 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							ad7111ad4d 
							
						 
					 
					
						
						
							
							* SysTinyFreeMem: terminate with a runtime error if Addr is >= HeapPtr, since  
						
						... 
						
						
						
						InternalTinyFreeMem cannot handle that (which causes heap corruption), and it
  indicates a bug in the program anyway, because the area between HeapPtr and
  HeapEnd is free (so it indicates either a double free or freeing an invalid
  pointer).
git-svn-id: trunk@28658 - 
						
					 
					
						2014-09-14 14:47:13 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							bb07318386 
							
						 
					 
					
						
						
							
							+ added RegisterTinyHeapBlock_Simple_Prealigned procedure, which is the same as  
						
						... 
						
						
						
						RegisterTinyHeapBlock_Simple, but expects its address and size parameters to
  be already aligned on a TinyHeapAllocGranularity boundary
git-svn-id: trunk@28651 - 
						
					 
					
						2014-09-13 15:35:46 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							c8e9d2cf6e 
							
						 
					 
					
						
						
							
							+ added a simplified version of RegisterTinyHeapBlock, for use when the tiny  
						
						... 
						
						
						
						heap is a single memory block
git-svn-id: trunk@28635 - 
						
					 
					
						2014-09-09 12:45:47 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							72ba70f7ec 
							
						 
					 
					
						
						
							
							* use HexStr instead of casting to PtrUInt for logging pointers, when  
						
						... 
						
						
						
						DEBUG_TINY_HEAP is defined, because HexStr produces nicer results for far
  pointers
git-svn-id: trunk@28633 - 
						
					 
					
						2014-09-09 00:47:25 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							bf8a7f0784 
							
						 
					 
					
						
						
							
							* handle properly the case when RegisterTinyHeapBlock is called with a start  
						
						... 
						
						
						
						address equal or larger than HeapEnd
git-svn-id: trunk@28621 - 
						
					 
					
						2014-09-08 17:45:09 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							af1c5096d6 
							
						 
					 
					
						
						
							
							* tiny heap made TP7 compatible; the FreeList and HeapPtr variables made public  
						
						... 
						
						
						
						git-svn-id: trunk@28612 - 
						
					 
					
						2014-09-07 19:41:53 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							e4095588d6 
							
						 
					 
					
						
						
							
							* the type of FreeList changed to an untyped pointer (TP7 compatibility)  
						
						... 
						
						
						
						git-svn-id: trunk@28608 - 
						
					 
					
						2014-09-06 18:52:43 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							a4d71348dd 
							
						 
					 
					
						
						
							
							* TinyHeapBlocks renamed FreeList for TP7 compatibility reasons (and it'll be  
						
						... 
						
						
						
						moved to the interface part of the system unit as soon as the tiny heap's free
  list becomes TP7 compatible)
git-svn-id: trunk@28607 - 
						
					 
					
						2014-09-06 14:56:04 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							9b41b10350 
							
						 
					 
					
						
						
							
							* implementation of tiny heap's GetMem changed, so that it doesn't use FreeMem  
						
						... 
						
						
						
						internally.
git-svn-id: trunk@28580 - 
						
					 
					
						2014-09-01 23:37:00 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							cd0acd050e 
							
						 
					 
					
						
						
							
							* store the tiny heap free block size in a TP7-compatible way (as a normalized  
						
						... 
						
						
						
						segment:offset pair, instead of a longint) in the i8086 far data memory models
git-svn-id: trunk@28532 - 
						
					 
					
						2014-08-28 21:24:41 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							03a838556f 
							
						 
					 
					
						
						
							
							* keep the tiny heap free blocks ordered by start address, instead of size.  
						
						... 
						
						
						
						Rationale: 1) TP7 compatibility, 2) easier debugging of heap corruption
  problems
git-svn-id: trunk@28518 - 
						
					 
					
						2014-08-24 16:07:01 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							70850f0ce6 
							
						 
					 
					
						
						
							
							+ tinyheap: check and generate runtime error 204 if an attempt is made to free a  
						
						... 
						
						
						
						memory block that is outside the heap
git-svn-id: trunk@28446 - 
						
					 
					
						2014-08-18 16:44:34 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							9979aa702f 
							
						 
					 
					
						
						
							
							+ added the TP7-compatible pointer variables HeapOrg and HeapEnd, indicating,  
						
						... 
						
						
						
						respectively, the start and end of the tiny heap. Eventually they are also
  going to be used for catching attempts to free memory that is outside the
  heap.
git-svn-id: trunk@28437 - 
						
					 
					
						2014-08-17 22:42:44 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							7986d0c2ca 
							
						 
					 
					
						
						
							
							* simplify RegisterTinyHeapBlock by calling InternalTinyFreeMem directly,  
						
						... 
						
						
						
						instead of FreeMem. We already do the alignments correctly, so going through
  FreeMem is no longer necessary.
git-svn-id: trunk@28428 - 
						
					 
					
						2014-08-16 22:51:06 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							2e0c40d33b 
							
						 
					 
					
						
						
							
							* TinyHeapAllocGranularity changed to SizeOf(TTinyHeapBlock). This fixes a bug  
						
						... 
						
						
						
						where the free blocks may become fragmented, even though all the memory has
  been freed, following certain allocation patterns.
git-svn-id: trunk@28419 - 
						
					 
					
						2014-08-15 22:13:23 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							902c25fafa 
							
						 
					 
					
						
						
							
							+ RegisterTinyHeapBlock: align the start address and size according to  
						
						... 
						
						
						
						TinyHeapAllocGranularity
git-svn-id: trunk@28418 - 
						
					 
					
						2014-08-15 16:10:22 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							815bfe0dcf 
							
						 
					 
					
						
						
							
							+ tiny heap alloc granularity moved to a constant TinyHeapAllocGranularity  
						
						... 
						
						
						
						git-svn-id: trunk@28417 - 
						
					 
					
						2014-08-15 15:22:51 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							14057ef438 
							
						 
					 
					
						
						
							
							* rm EndAddr from the TTinyHeapBlock structure. This:  
						
						... 
						
						
						
						1) fixes a bug, which causes the next TTinyHeapBlock to be overwritten after
     freeing a memory block, allocated by GetMem(sizeof(pointer)). This bug was
     exposed after r28391, but was present before that; this commit only made
     the damage worse and, therefore, more visible.
  2) brings the internal heap structure closer to the TP7 heap.
git-svn-id: trunk@28416 - 
						
					 
					
						2014-08-15 00:33:33 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							21246e973a 
							
						 
					 
					
						
						
							
							* TinyHeapMinBlock defined as sizeof(TTinyHeapBlock), as that's the smallest  
						
						... 
						
						
						
						free block actually supported
git-svn-id: trunk@28401 - 
						
					 
					
						2014-08-13 08:44:53 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							e8c1a44068 
							
						 
					 
					
						
						
							
							* swapped the order of the Next and Size fields in TTinyHeapBlock, because that  
						
						... 
						
						
						
						brings it closer (but still not equal) to the TP7 heap's internal structure
git-svn-id: trunk@28391 - 
						
					 
					
						2014-08-12 20:38:08 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							6720f84d24 
							
						 
					 
					
						
						
							
							+ switch to using huge pointers in the tiny heap in the i8086 far data memory  
						
						... 
						
						
						
						models
git-svn-id: trunk@28333 - 
						
					 
					
						2014-08-07 21:15:56 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							9a569b9e57 
							
						 
					 
					
						
						
							
							* use P/TTinyHeapMemBlockSize in RegisterTinyHeapBlock as well  
						
						... 
						
						
						
						git-svn-id: trunk@28248 - 
						
					 
					
						2014-07-22 12:51:20 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							6f8a329b4c 
							
						 
					 
					
						
						
							
							* use pointer arithmetic for doing address calculations, with a newly introduced  
						
						... 
						
						
						
						pointer type TTinyHeapPointerArithmeticType, instead of using ptruint. This
  will allow us to use a huge pointer in i8086 far data memory models, in order
  to allow the heap to exceed 64k.
git-svn-id: trunk@28247 - 
						
					 
					
						2014-07-21 23:02:49 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							3b9ab33910 
							
						 
					 
					
						
						
							
							* added type TTinyHeapFreeBlockSize, which holds the size of a free memory block  
						
						... 
						
						
						
						in the tiny heap
git-svn-id: trunk@28246 - 
						
					 
					
						2014-07-21 17:05:52 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							1dc09538d0 
							
						 
					 
					
						
						
							
							* introduce a type TTinyHeapMemBlockSize, which holds the size of an allocated  
						
						... 
						
						
						
						memory block in the tiny heap
git-svn-id: trunk@28245 - 
						
					 
					
						2014-07-20 16:31:40 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							4e2cc365d1 
							
						 
					 
					
						
						
							
							* while loop replaced with a repeat..until loop in InternalTinyFreeMem  
						
						... 
						
						
						
						git-svn-id: trunk@28161 - 
						
					 
					
						2014-07-05 09:47:59 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							640f6ea300 
							
						 
					 
					
						
						
							
							* return nil in SysTinyReallocMem, when the size parameter is 0  
						
						... 
						
						
						
						git-svn-id: trunk@26892 - 
						
					 
					
						2014-02-26 23:31:50 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							858efec84e 
							
						 
					 
					
						
						
							
							* handle SysTinyFreeMem(nil) properly (i.e. succeed silently, without writing to  
						
						... 
						
						
						
						nil pointer memory)
git-svn-id: trunk@26890 - 
						
					 
					
						2014-02-26 22:01:50 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							327a15488e 
							
						 
					 
					
						
						
							
							* generate a run time error 203 in the tiny heap in case there's not enough  
						
						... 
						
						
						
						memory for a memory allocation and ReturnNilIfGrowHeapFails is false
git-svn-id: trunk@25727 - 
						
					 
					
						2013-10-09 19:27:55 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							6695c8578f 
							
						 
					 
					
						
						
							
							* set the TinyHeapMinBlock const relative to the pointer size  
						
						... 
						
						
						
						git-svn-id: trunk@24521 - 
						
					 
					
						2013-05-16 22:17:05 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							f0ada1ccc5 
							
						 
					 
					
						
						
							
							* fixed bug in SysTinyGetMem that caused heap corruption if the free block that's being allocated is followed tightly by an already allocated block  
						
						... 
						
						
						
						git-svn-id: trunk@24520 - 
						
					 
					
						2013-05-16 22:15:36 +00:00 
						 
				 
			
				
					
						
							
							
								nickysn 
							
						 
					 
					
						
						
						
						
							
						
						
							9312419ce8 
							
						 
					 
					
						
						
							
							* fixed heap block start and size alignment in RegisterTinyHeapBlock  
						
						... 
						
						
						
						git-svn-id: trunk@24519 - 
						
					 
					
						2013-05-16 22:13:35 +00:00