<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Seems that I found a workaround.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>When calling the NewSubChunk in the following syntax:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>SubChunks[NewSubChunk]^.read(fl);  /// raise an exception.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>While<o:p></o:p></span></p><p class=MsoNormal><a name="_MailEndCompose"><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>MyIndex := NewSubChunk;<o:p></o:p></span></a></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>SubChunks[MyIndex]^.read(fl);  /// raise an exception.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Doesn't raise any excetion…. <o:p></o:p></span></p><div style='mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt;padding:0cm 0cm 1.0pt 0cm'><p class=MsoNormal style='border:none;padding:0cm'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Maybe the experts could say why, I don't know why…<o:p></o:p></span></p></div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Amit<o:p></o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> fpc-pascal-bounces@lists.freepascal.org [mailto:fpc-pascal-bounces@lists.freepascal.org] <b>On Behalf Of </b>ik<br><b>Sent:</b> Wednesday, February 02, 2011 5:48 PM<br><b>To:</b> FPC-Pascal users discussions<br><b>Subject:</b> Re: [fpc-pascal] dynamic array and new/dispose<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>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><o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'>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><o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'><br><br><o:p></o:p></p><div><p class=MsoNormal>On Wed, Feb 2, 2011 at 17:29, Amit Bueno <<a href="mailto:amitbueno@gmail.com">amitbueno@gmail.com</a>> wrote:<o:p></o:p></p><div><div><p class=MsoNormal>Of course it does -- otherwise it won't have worked on delphi under windows.<o:p></o:p></p></div><div><p class=MsoNormal>The X = High(SubChunks);<o:p></o:p></p></div><div><p class=MsoNormal>---<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>Amit<o:p></o:p></p></div><div><div><div><p class=MsoNormal>On Wed, Feb 2, 2011 at 5:27 PM, ik <<a href="mailto:idokan@gmail.com" target="_blank">idokan@gmail.com</a>> wrote:<o:p></o:p></p><div><div><div><p class=MsoNormal>On Wed, Feb 2, 2011 at 17:18, Amit Bueno <<a href="mailto:amitbueno@gmail.com" target="_blank">amitbueno@gmail.com</a>> wrote:<o:p></o:p></p><div><div><p class=MsoNormal>The SubChunks are -- 'var subchunks array of pchunk;' contained in chunk<o:p></o:p></p></div><div><p class=MsoNormal>before allocating the subchunks a setlength(subchunks, High(subchunks)+2) is called.<o:p></o:p></p></div></div></div><div><p class=MsoNormal><br>But does the X variable point to existed index in the array ? if not, then it explains the "access violation".<br> <o:p></o:p></p></div><div><div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal>---<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>Amit<o:p></o:p></p></div><div><div><div><p class=MsoNormal>On Wed, Feb 2, 2011 at 5:15 PM, ik <<a href="mailto:idokan@gmail.com" target="_blank">idokan@gmail.com</a>> wrote:<o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'><br><br><o:p></o:p></p><div><p class=MsoNormal>On Wed, Feb 2, 2011 at 16:57, Amit Bueno <<a href="mailto:amitbueno@gmail.com" target="_blank">amitbueno@gmail.com</a>> wrote:<o:p></o:p></p><div><div><p class=MsoNormal>Seems that the ios doesn't allocated properly my objects,. after allocation when trying to run a function from the object it fails.<o:p></o:p></p></div><div><p class=MsoNormal>I tried replacing the New(subchunks[X]) to SubChunks[X] := AllocMem(sizeof(Chunk));<o:p></o:p></p></div><div><p class=MsoNormal>Again this works on the windows, it doesn't on the ios.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>Have you got any ideas?<o:p></o:p></p></div></div><div><p class=MsoNormal><br>Does "X" actually exists as an index (I mean the value of it) ?<br><br> <o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal>---<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>Amit<o:p></o:p></p></div><div><div><div><p class=MsoNormal>On Wed, Feb 2, 2011 at 3:34 PM, Amit Bueno <<a href="mailto:amitbueno@gmail.com" target="_blank">amitbueno@gmail.com</a>> wrote:<o:p></o:p></p><p class=MsoNormal>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> <o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><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<o:p></o:p></p></div></div><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>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><o:p></o:p></p></div></div><div><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>On 02 Feb 2011, at 14:10, Amit Bueno wrote:<br><br>> Have you got the prof.rar?<o:p></o:p></p></div><p class=MsoNormal>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.<o:p></o:p></p><div><div><p class=MsoNormal><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><o:p></o:p></p></div></div></div></div></div><p class=MsoNormal><o:p> </o:p></p></div></div></div><div><div><p class=MsoNormal><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><o:p></o:p></p></div></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><br>Ido<br clear=all><o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'>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><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div><p class=MsoNormal><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><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></div><p class=MsoNormal><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><o:p></o:p></p></blockquote></div></div></div><div><div><p class=MsoNormal style='margin-bottom:12.0pt'><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><o:p></o:p></p></div></div></div><p class=MsoNormal><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><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></div><p class=MsoNormal><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><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>