Hi,

I don't quite agree with Per's explanation, at least not as far as SMSQ/E is concerned.

Once the memory is allocated, A0 points past the header, as Per said.

So, at -4(a0) you will find chp_flag, not chp_len.

Moreover, chp_flag is used by the system :

Consider how SMSQ/E releases memory reserved on the common heap
(in smsq_mem_rchp_asm)

        movem.l reglist,-(sp)           save volatiles
        moveq   #chp.free,d0
        move.l  d0,chp_ownr(a0)         set owner free
        move.l  chp_flag(a0),d0         flag address
        beq.s   mrc_rehp                is empty, do nothing
        move.l  d0,a1                   set flag...
        st      (a1)                    ...now
*
So what happens here is that, if chp_flag isn't empty, the address
it points to will have its MSB set. If you put "grab" in there, then address $67726162 will have its MSB set to 1.

OK, that most likely won't be a problem because in most cases that address doesn't exist. But what if you put something else than "grab" at chp_flag and that points to somewhere in real memory? Oops...

So your initial way of doing things definitely is the right way.


HTH

Wolfgang

_______________________________________________
QL-Users Mailing List

Reply via email to