Heap

Just starting out? Need help? Post your questions and find answers here.
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

Heap

Post by 4RESTER »

How to get the:
heap_id
heap_base


of the AllocatedMemory ?


*mem_id = AllocateMemory(1024)

heap_base = *mem_id ?
See ya... Image
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Heap

Post by STARGÅTE »

PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

Re: Heap

Post 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_(
?
See ya... Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Heap

Post by ts-soft »

Use API or PB, ReAllocateMemory should do it.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

Re: Heap

Post 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
See ya... Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Heap

Post by ts-soft »

Code: Select all

Define *mem = HeapAlloc_(GetProcessHeap_(), $08, 100)
Define *mem2
If *mem
  *mem2 = HeapReAlloc_(GetProcessHeap_(), $08, *mem, 200)
EndIf
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

Re: Heap

Post 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)
See ya... Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Heap

Post 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) 
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

Re: Heap

Post 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 ?
See ya... Image
Post Reply