[fpc-devel] porting from fpc to tp7
Evgeniy Ivanov
lolkaantimat at gmail.com
Sat Mar 24 11:30:02 CET 2007
On Sat, 24 Mar 2007 13:05:54 +0300, Daniƫl Mantione
<daniel.mantione at freepascal.org> wrote:
>> procedure add_mem(var P: dynamic_array_ptr; var cur_size:Integer);
>> var
>> i:Integer;
>> buff_ptr:dynamic_array_ptr;
>> begin
>> getmem(buff_ptr,cur_size*sizeof(BusStation) );
>> for i:=1 to cur_size do
>> buff_ptr^[i] := P^[i];
>> freemem(P);
>> cur_size:=cur_size+buf_count;
>> getmem(P,cur_size*sizeof(BusStation) );
>> for i:=1 to (cur_size-buf_count) do
>> P^[i] := buff_ptr^[i];
>> freemem(buff_ptr);
>> cur_size:=cur_size+buf_count;
>> end;
>
> Why do you increase cur_size two times? At the end of the procedure
> cur_size is larger than the buffer is.
Ou, surely. But it is new bug. When I used tp there was'n second increase.
Also buf_count value is 10 and I have tried to add only 5 elements. After
second startup the problems have begun.
> Further, you want to use move instead of a for loop, since in TP the
> speed difference is even larger than in FP.
Sorry, but I didn't understand what you ment exactly. You ment to use
ptr_buf = P and then getmem(P) and for loop?
--
Best regards
E.I.
More information about the fpc-devel
mailing list