Allow reallocation of memory handles to 0 pages.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1231
This commit is contained in:
		
							parent
							
								
									20083140da
								
							
						
					
					
						commit
						7d2bdc65e3
					
				
					 1 changed files with 10 additions and 4 deletions
				
			
		|  | @ -565,11 +565,17 @@ void MEM_ReleasePages(MemHandle handle) { | |||
| } | ||||
| 
 | ||||
| bool MEM_ReAllocatePages(MemHandle & handle,Bitu pages,bool sequence) { | ||||
| 	MemHandle index=handle; | ||||
| 	if (index<0 || !pages) { | ||||
| 		E_Exit("MEM:Resized to size 0"); | ||||
| 		return 0; | ||||
| 	if (handle<0) { | ||||
| 		if (!pages) return true; | ||||
| 		handle=MEM_AllocatePages(pages,sequence); | ||||
| 		return (handle>0); | ||||
| 	} | ||||
| 	if (!pages) { | ||||
| 		MEM_ReleasePages(handle); | ||||
| 		handle=-1; | ||||
| 		return true; | ||||
| 	} | ||||
| 	MemHandle index=handle; | ||||
| 	MemHandle last;Bitu old_pages=0; | ||||
| 	while (index>0) { | ||||
| 		old_pages++; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue