<HTML><BODY>> Allocate `giarg' with `(malloc 'nonatomic ...)` and never install a<br> non-pointer value into it.<br><br>When I allocate giarg, I don't know yet, what type it will store. It is _union...<br><br>> Allocate the string's memory with `(malloc 'atomic-interior ...)`<br><br>So it should be something like (struct giarg (ptr string-ptr)). And I should set giarg-string-ptr whenever I ptr-set! giarg-ptr _string.<br>I think, it is best option.<br><br>Thank you!<br><br><br>Воскресенье, 1 сентября 2013, 11:10 -06:00 от Matthew Flatt <mflatt@cs.utah.edu>:<br>
<blockquote style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(8, 87, 166); margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 10px; position: static; z-index: auto; " class="mailru-blockquote">
        <div id="">
        
        
        
        
        
        
        
        
<div class="js-helper js-readmsg-msg">
        <style type="text/css"></style>
        <div id="style_13780554500000000817" class="mr_read__body">
                <base target="_self" href="https://e.mail.ru/">
                
                        <div id="style_13780554500000000817_BODY">You're right --- the string can be GC'ed at any time.<br>
<br>
There are a few ways to solve the problem:<br>
<br>
* Allocate `giarg' with `(malloc 'nonatomic ...)` and never install a<br>
non-pointer value into it.<br>
<br>
* Allocate the string's memory with `(malloc 'atomic-interior ...)`<br>
and arrange for that memory to be referenced from some GC-visible<br>
place for as long as it can be referenced by `giarg`.<br>
<br>
* Allocate the string's memory with `(malloc 'raw ...)` and explicitly<br>
`free` it when `giarg` is no longer used.<br>
<br>
At Sun, 01 Sep 2013 17:38:26 +0400, Roman Klochkov wrote:<br>
> (define _giarg (_union _bool _int8 _uint8 _int16 _uint16<br>
> _int32 _uint32 _int64 _uint64<br>
> _float _double _long _ulong _pointer _string))<br>
> <br>
> (define giarg (malloc _giarg)) (ptr-set! giarg _string "Test string")<br>
> <br>
> ---<br>
> <br>
> It works. But I'm afraid, that string maybe allocated temporary and will be <br>
> GC'ed at any time. Or _union keep _string pointer inside?<br>
<br>
</div>
                        
                
                <base target="_self" href="https://e.mail.ru/">
        </div>
        
</div>
</div>
</blockquote>
<br>
<br>--
<br>Roman Klochkov<br></BODY></HTML>