Snippet Recycle

Azlier

Old World Ghost
Reaction score
461
The only real use for recycled triggers are for Events. And that's almost never needed.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Do you still have to null locals? I saw some people's code using this but they weren't nulling.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I don't see the usefulness of it in the current state, since with this library only, you can't attach an integer (struct) to a timer -> TimerUtils.
You also doesn't prevent double free, at least in debug mode, same for groups -> GroupUtils (but i don't like this last code to be honest).
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Sometimes i use groups for more than an instant, even if this case is minor i still prefer have a GroupRefresh function.
But as i said, i really don't like the way how GroupUtils was build, in fact i've edited it for myself.
The result, the speed is actually the same as this script in not debug mode, and in debug mode it prevents me for double free.
 

Jesus4Lyf

Good Idea™
Reaction score
397
The result, the speed is actually the same as this script in not debug mode, and in debug mode it prevents me for double free.
Cool! :D

This script could prevent double free, the cost is it cannot be used on 1.23 (rapidly fading usefulness). :p

Could ask Nestharus to add it.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Bwah honestly i don't care about that for this script, since i won't use it anyway, because of what i said.

Or maybe you have an other idea of recycling which is not a group, neither a timer ?

Btw i used a dummy unit for group utils, so it's still fully compatible with all versions of war3, but ofc it can't be used for this generic handle script.

EDIT : Heh i forgot the new static ifs, you could generate this kind of script.
If you don't know how, simply declare a boolean with the textmacro and use it in a static if to generate the right code.
But still ofc i guess we can't work like that with all handle types.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Btw i used a dummy unit for group utils, so it's still fully compatible with all versions of war3, but ofc it can't be used for this generic handle script.
Using something like that for double free protection seems counter-intuitive. Surely, the unit may have been removed from the group before being freed for a second time - such as if any enum was called for it...
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Using something like that for double free protection seems counter-intuitive. Surely, the unit may have been removed from the group before being freed for a second time - such as if any enum was called for it...

The unit is inside freed groups only and a debug message is displayed if you try to freed it again, but maybe i've missed something.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Yes, if the group is used at all with an Enum or FoG loop, your protection is shot. You seemingly would only save double free protection if it is immediately two calls. But that's not very useful... most likely the user (yourself? XD) would accidentally keep a reference to the group, and try using it for something, and then free it again...

Hm.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Yes, if the group is used at all with an Enum or FoG loop, your protection is shot. You seemingly would only save double free protection if it is immediately two calls. But that's not very useful... most likely the user (yourself? XD) would accidentally keep a reference to the group, and try using it for something, and then free it again...

Hm.

I don't use myself FoG loop, hence the reason.
Bwah i guess personal codes are perfect for personal purposes.

I just want to add that double free can happen more quickly than you think, even if you're the best coder ever.
 

Nestharus

o-o
Reaction score
84
On Data Attachment
Actually, I was thinking of doing an add-on to this (a module) that would do data attachment on timers and groups, but I stopped it. The reason is it'd only be a few lines.. it'd just get an offset... it'd be such a tiny little script, lol. From there you'd use the offset for the array index =).

This would actually be the code for it ^^

JASS:
library Memory initializer Initialization uses Recycle
{
    struct Memory {
        public static int offset
        
        public static timer privateTimer = CreateTimer()
        public static integer array data
        define <Memory.set>(handleId, value) = {
            Memory.data[handleId-Memory.offset] = value
        }
        
        define <Memory.get>(handleId) = {
            Memory.data[handleId-Memory.offset]
        }
        
        public hashtable memory = InitHashtable()
        define <Memory.set>(handleId, slot, value) = {
            SaveInteger(Memory.memory, handleId, slot, value)
        }
        
        define <Memory.get>(handleId, slot) = {
            LoadInteger(Memory.memory, handleId, slot)
        }
    }

    private void Initialization() {
        Memory.offset = GetHandleId(Memory.privateTimer)
        Timer.release(Memory.privateTimer)
        Memory.privateTimer = null
    }
}



And here is a demo
JASS:
include "cj_types.j"
include "cj_typesEx.j"
include "cj_print.j"
include "cj_types_priv.j"  
include "cj_typesEx_priv.j"
include "cj_order.j"  
include "cj_antibj_base.j"


scope Demo initializer Initialization {
    timer t
    int data
    
    void Test() {
        data = Memory.get(GetHandleId(GetExpiredTimer()))
        printf(I2S(data))
    }
    
    void Initialization() {
        t = Timer.get()
        Memory.set(GetHandleId(t), 5)
        TimerStart(t, 1, false, function Test)
    }
}



So do you guys really want me to submit this (when and if cJASS gets approved, lol)
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Yes, if the group is used at all with an Enum or FoG loop, your protection is shot. You seemingly would only save double free protection if it is immediately two calls. But that's not very useful... most likely the user (yourself? XD) would accidentally keep a reference to the group, and try using it for something, and then free it again...
Wait, what? You can double-free with groups? I haven't been able to find any mention of how that can happen. Could you explain?
 

Nestharus

o-o
Reaction score
84
He's talking about Troll-Brain's method of double free protection =P


But yes, you could in fact double free a group with Recycle too : )


Group.release(group1)
Group.release(group1)

and there is the double free : D
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Oh, so it's a system-index double-free, not a handle double-free as can happen with destroying timers or triggeractions?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air

      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