Page 1 of 1

Heap

Posted: Fri Apr 29, 2011 8:05 pm
by 4RESTER
How to get the:
heap_id
heap_base


of the AllocatedMemory ?


*mem_id = AllocateMemory(1024)

heap_base = *mem_id ?

Re: Heap

Posted: Fri Apr 29, 2011 8:42 pm
by STARGÅTE

Re: Heap

Posted: Fri Apr 29, 2011 9:13 pm
by 4RESTER
STARGÅTE wrote:help this link?
http://www.purebasic.fr/blog/?p=55
Not help.

How to get heap_base & heap_addr to use with the:
*mem_id = HeapReAlloc_(
?

Re: Heap

Posted: Fri Apr 29, 2011 9:31 pm
by ts-soft
Use API or PB, ReAllocateMemory should do it.

Re: Heap

Posted: Fri Apr 29, 2011 9:56 pm
by 4RESTER
ts-soft wrote:Use API or PB, ReAllocateMemory should do it.
Work effectively only through:
function HeapReAlloc(
hHeap: THandle;
dwFlags: DWORD;
lpMem: Pointer;
dwBytes: DWORD
): Pointer; stdcall;

So I'm asking how to get hHeap and lpMem, for use in PureBasic
by calling
HeapReAlloc_(

I do not need approval, I need a working example :D

Re: Heap

Posted: Fri Apr 29, 2011 11:08 pm
by ts-soft

Code: Select all

Define *mem = HeapAlloc_(GetProcessHeap_(), $08, 100)
Define *mem2
If *mem
  *mem2 = HeapReAlloc_(GetProcessHeap_(), $08, *mem, 200)
EndIf

Re: Heap

Posted: Sat Apr 30, 2011 12:58 am
by 4RESTER
ts-soft wrote:

Code: Select all

Define *mem = HeapAlloc_(GetProcessHeap_(), $08, 100)
Define *mem2
If *mem
  *mem2 = HeapReAlloc_(GetProcessHeap_(), $08, *mem, 200)
EndIf
10x a lot!

This work:

Code: Select all

*mem = AllocateMemory(100)
PokeL(*mem+$0000, $12345678)

*mem = HeapReAlloc_(GetProcessHeap_(), $08, *mem, 200)
Debug StrU(MemorySize(*mem))
Debug PeekL(*mem+$0000)

Re: Heap

Posted: Sat Apr 30, 2011 1:12 am
by ts-soft
doesn't work on my pc, but this works:

Code: Select all

*mem = AllocateMemory(100)
PokeL(*mem + $0000, $12345678)

*mem = ReAllocateMemory(*mem, 200)
Debug StrU(MemorySize(*mem))
Debug PeekL(*mem + $0000) 

Re: Heap

Posted: Mon Jan 30, 2012 7:15 pm
by 4RESTER
ts-soft wrote:doesn't work on my pc, but this works:

Code: Select all

*mem = AllocateMemory(100)
PokeL(*mem + $0000, $12345678)

*mem = ReAllocateMemory(*mem, 200)
Debug StrU(MemorySize(*mem))
Debug PeekL(*mem + $0000) 

May be into the PureBasic exist constant the Heap ID of task, like #PB_HEAP ?