Pseudodynamic memory manager

xPheRe

New Member
Reaction score
43
Hi! I'm new posting in the forum, but I have learned all about WE reading posts here and with some "try and error". I coded some JASS and decide to send it. Maybe it can help anyone. Maybe not. I've only coded it as a coding exercise.

It is a pseudodynamic memory manager, it's able to alloc and release chunks of data at runtime. Maybe it's similar to the HeapGet of WEU, in the sense that uses a huge array to store data, but I think it's more powerful, fast and versatile. It's easily modifiable to allow other kind of storage, like a bunch of arrays or gamecaches, whatever.

In the example the wisps allocates and deallocates random sized blocks of random data. If you click a wisp with linked data, it will tell you what data carries.

Hope someone finds it usefull, and hope to send some maps and campaings soon too.

Thanks to all!

(Edit: Link to the old attachment here)
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
:eek:

Possible error:
Code:
// Sets the data of a block from BEGIN to END, both included, to value VALUE
function xClear takes integer begin, integer end, integer value returns nothing
    local integer it = begin
    loop
        exitwhen it == end

        call xSet(it, value)
        set it = it + 1
    endloop
endfunction
It doesnt set udg_zzz_Memory[end] = vaule it quit before it sets
 

AgentPaper

From the depths, I come.
Reaction score
107
thid should go in the free codes thread, its a stcky at the top.
 

xPheRe

New Member
Reaction score
43
phyrex1an said:
It doesnt set udg_zzz_Memory[end] = vaule it quit before it sets
Yes, that's right. The comment at the top of the function is OK but the code is wrong. The line "exitwhen it == end" should be "exitwhen it > end" :banghead:

I haven't tested the code a lot, so this minor bug passed me by. Thanks!

AgentPaper said:
thid should go in the free codes thread, its a stcky at the top.
The truth is that I didn't know where to post it :confused: And it would be GREAT if it's sticky, thx :) :) :) :)

Here's a corrected version without the xClear bug
Soon I hope to add some features like reallocation and a linked list system based on this one (like WEU has)
 

xPheRe

New Member
Reaction score
43
I would be interested in knowing if anybody finds this useful and for what kind of stuff :)
If it's not... well, at least it was a great coding exercise :D
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Im_On_56k said:
Simply go into that thread and post your map, jass code there.
It is allredy there ^^

xPheRe said:
I would be interested in knowing if anybody finds this useful and for what kind of stuff :)
If it's not... well, at least it was a great coding exercise :D

This should be VERY usefull, if it wasnt fore one thing: The return bug (not a bug in your code), the return bug and a game cache allredy do this and without an array and with a very short code. It is able to store units as well.

Check it out: http://www.wc3jass.com/viewtopic.php?t=224 (Local Handle Variables)

Your code has one advantage, it doesnt leak if a unit dies. The Local Handle Variables does if the unit isnt "cleaned".

One thing it still is usefull for is: Make me better at programming^^
 

xPheRe

New Member
Reaction score
43
I thought the "Free trigger code" thread was for short snippets of code/triggers, so I wrote a post with a simple func to shufle the content of an array.
Anyhow, There's any way to move the first post of this thread to the "Free trigger code" thread?
Thx for all, phyrex1an, Im_On_56k, if there's a way I can help, you only have to mention it ;)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top