mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 11:53:42 +01:00 
			
		
		
		
	* fixed internal_memavail counting for tryresizemem
This commit is contained in:
		
							parent
							
								
									0fc3f2e559
								
							
						
					
					
						commit
						6bbb440811
					
				| @ -536,6 +536,7 @@ end; | |||||||
| 
 | 
 | ||||||
| function SysTryResizeMem(var p:pointer;size : longint):boolean; | function SysTryResizeMem(var p:pointer;size : longint):boolean; | ||||||
| var | var | ||||||
|  |   oldsize, | ||||||
|   currsize, |   currsize, | ||||||
|   foundsize, |   foundsize, | ||||||
|   sizeleft, |   sizeleft, | ||||||
| @ -550,6 +551,7 @@ begin | |||||||
| { fix p to point to the heaprecord } | { fix p to point to the heaprecord } | ||||||
|   pcurr:=pfreerecord(pointer(p)-sizeof(theaprecord)); |   pcurr:=pfreerecord(pointer(p)-sizeof(theaprecord)); | ||||||
|   currsize:=pcurr^.size and sizemask; |   currsize:=pcurr^.size and sizemask; | ||||||
|  |   oldsize:=currsize; | ||||||
|   wasbeforeheapend:=(pcurr^.size and beforeheapendmask)<>0; |   wasbeforeheapend:=(pcurr^.size and beforeheapendmask)<>0; | ||||||
| { is the allocated block still correct? } | { is the allocated block still correct? } | ||||||
|   if currsize=size then |   if currsize=size then | ||||||
| @ -655,6 +657,7 @@ begin | |||||||
|         pcurr^.size:=size or usedmask or (pcurr^.size and beforeheapendmask); |         pcurr^.size:=size or usedmask or (pcurr^.size and beforeheapendmask); | ||||||
|       end; |       end; | ||||||
|    end; |    end; | ||||||
|  |   dec(internal_memavail,size-oldsize); | ||||||
|   SysTryResizeMem:=true; |   SysTryResizeMem:=true; | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| @ -672,16 +675,14 @@ begin | |||||||
|    begin |    begin | ||||||
|      if p<>nil then |      if p<>nil then | ||||||
|       MemoryManager.FreeMem(p); |       MemoryManager.FreeMem(p); | ||||||
|      SysReallocmem:=P; |    end | ||||||
|      exit; |   else | ||||||
|    end; |  | ||||||
|    { Allocate a new block? } |    { Allocate a new block? } | ||||||
|    if p=nil then |    if p=nil then | ||||||
|     begin |     begin | ||||||
|       p:=MemoryManager.GetMem(size); |       p:=MemoryManager.GetMem(size); | ||||||
|      SysReallocmem:=P; |     end | ||||||
|      exit; |   else | ||||||
|    end; |  | ||||||
|    { Resize block } |    { Resize block } | ||||||
|    if not SysTryResizeMem(p,size) then |    if not SysTryResizeMem(p,size) then | ||||||
|     begin |     begin | ||||||
| @ -804,7 +805,10 @@ end; | |||||||
| 
 | 
 | ||||||
| { | { | ||||||
|   $Log$ |   $Log$ | ||||||
|   Revision 1.32  2000-01-31 23:41:30  peter |   Revision 1.33  2000-02-02 11:12:29  peter | ||||||
|  |     * fixed internal_memavail counting for tryresizemem | ||||||
|  | 
 | ||||||
|  |   Revision 1.32  2000/01/31 23:41:30  peter | ||||||
|     * reallocmem fixed for freemem() call when size=0 |     * reallocmem fixed for freemem() call when size=0 | ||||||
| 
 | 
 | ||||||
|   Revision 1.31  2000/01/24 23:56:10  peter |   Revision 1.31  2000/01/24 23:56:10  peter | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 peter
						peter