<div dir="ltr">I have created a proof of concept from your code:<br><br>----------------------------<br>{$mode delphi}<br>program test;<br><br>type<br> PChunk = ^Chunk;<br> Chunk = Object<br> SubChunks : array of PChunk;<br>
data : Pointer;<br> Function NewSubchunk: integer;<br> end;<br><br>function Chunk.NewSubchunk :integer;<br>var<br> x : integer;<br>begin<br> x := High(SubChunks)+2;<br> setlength(SubChunks, x); <br> New(subchunks[x]);<br>
SubChunks[x]^.Data := Self.Data;<br> Result := x;<br>end;<br><br>var<br> ac : Chunk; <br><br>begin<br> ac.data := PChar('Hello world');<br> writeln(ac.NewSubchunk);<br>end.<br><br>-----------------------<br><br>
Does it work for you (I do not have any apple to test it on, but it works on my Linux) ?<br><br>And yes it leaks memory :)<br><br>Ido<br clear="all"><div dir="ltr">LINESIP - Opening the source for communication<br><a href="http://www.linesip.com" target="_blank">http://www.linesip.com</a><br>
<a href="http://www.linesip.co.il" target="_blank">http://www.linesip.co.il</a><br><br></div><br>
<br><br><div class="gmail_quote">On Wed, Feb 2, 2011 at 17:29, Amit Bueno <span dir="ltr"><<a href="mailto:amitbueno@gmail.com">amitbueno@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr"><div>Of course it does -- otherwise it won't have worked on delphi under windows.</div>
<div>The X = High(SubChunks);</div>
<div>---</div>
<div>Amit<font color="#888888"><br><br></font></div><div><div></div><div class="h5">
<div class="gmail_quote">On Wed, Feb 2, 2011 at 5:27 PM, ik <span dir="ltr"><<a href="mailto:idokan@gmail.com" target="_blank">idokan@gmail.com</a>></span> wrote:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div dir="ltr">
<div class="gmail_quote">
<div>On Wed, Feb 2, 2011 at 17:18, Amit Bueno <span dir="ltr"><<a href="mailto:amitbueno@gmail.com" target="_blank">amitbueno@gmail.com</a>></span> wrote:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div dir="ltr">
<div>The SubChunks are -- 'var subchunks array of pchunk;' contained in chunk</div>
<div>before allocating the subchunks a setlength(subchunks, High(subchunks)+2) is called.</div></div></blockquote></div>
<div><br>But does the X variable point to existed index in the array ? if not, then it explains the "access violation".<br> </div>
<div>
<div></div>
<div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div dir="ltr">
<div>---</div>
<div>Amit<font color="#888888"><br><br></font></div>
<div>
<div></div>
<div>
<div class="gmail_quote">On Wed, Feb 2, 2011 at 5:15 PM, ik <span dir="ltr"><<a href="mailto:idokan@gmail.com" target="_blank">idokan@gmail.com</a>></span> wrote:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div dir="ltr"><br><br><br>
<div class="gmail_quote">On Wed, Feb 2, 2011 at 16:57, Amit Bueno <span dir="ltr"><<a href="mailto:amitbueno@gmail.com" target="_blank">amitbueno@gmail.com</a>></span> wrote:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div dir="ltr">
<div>Seems that the ios doesn't allocated properly my objects,. after allocation when trying to run a function from the object it fails.</div>
<div>I tried replacing the New(subchunks[X]) to SubChunks[X] := AllocMem(sizeof(Chunk));</div>
<div>Again this works on the windows, it doesn't on the ios.</div>
<div> </div>
<div>Have you got any ideas?</div></div></blockquote>
<div><br>Does "X" actually exists as an index (I mean the value of it) ?<br><br> </div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div dir="ltr">
<div>---</div>
<div>Amit<br><br></div>
<div>
<div></div>
<div>
<div class="gmail_quote">On Wed, Feb 2, 2011 at 3:34 PM, Amit Bueno <span dir="ltr"><<a href="mailto:amitbueno@gmail.com" target="_blank">amitbueno@gmail.com</a>></span> wrote:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;" class="gmail_quote">Attached is the shrinked prof.rar file (481kb).<br>You can download it as well from:<br><a href="http://bueno.co.il/files/prof.rar" target="_blank">http://bueno.co.il/files/prof.rar</a>
<div><br>
<div><br>---<br>Amit<br><br>-----Original Message-----<br>From: <a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a><br>[mailto:<a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a>] On Behalf Of Jonas Maebe<br>
</div></div>
<div>
<div>Sent: Wednesday, February 02, 2011 3:28 PM<br>To: FPC-Pascal users discussions<br>Subject: Re: [fpc-pascal] dynamic array and new/dispose<br><br><br></div></div>
<div>
<div></div>
<div>
<div>On 02 Feb 2011, at 14:10, Amit Bueno wrote:<br><br>> Have you got the prof.rar?<br><br></div>No. I've just looked at the posts held for moderation and your mail is over<br>5MB. That is way too large to send to a mailing list. First of all, make<br>
sure to only include source code, not compiled units, programs or resources.<br>Secondly, if it's that big, put it online on a website and only send the<br>link to the mailing list.<br>
<div>
<div></div>
<div><br><br>Jonas<br>_______________________________________________<br>fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div><br>_______________________________________________<br>fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br>
<div><br>Ido<br clear="all">
<div dir="ltr">LINESIP - Opening the source for communication<br><a href="http://www.linesip.com/" target="_blank">http://www.linesip.com</a><br><a href="http://www.linesip.co.il/" target="_blank">http://www.linesip.co.il</a><br>
<br></div><br></div></div><br>_______________________________________________<br>fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</blockquote></div><br></div></div></div><br>_______________________________________________<br>fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br></blockquote></div></div></div>
<div>
<div></div>
<div><br><br>Ido<br clear="all">LINESIP - Opening the source for communication<br><a href="http://www.linesip.com/" target="_blank">http://www.linesip.com</a><br><a href="http://www.linesip.co.il/" target="_blank">http://www.linesip.co.il</a><br>
<br></div></div></div><br>_______________________________________________<br>fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br></blockquote></div><br></div>