|
@@ -34,6 +34,7 @@ type
|
|
eletype : pdynarraytypeinfo;
|
|
eletype : pdynarraytypeinfo;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+
|
|
function fpc_dynarray_rangecheck(p : pointer;i : tdynarrayindex) : tdynarrayindex;[Public,Alias:'FPC_DYNARRAY_RANGECHECK']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
|
function fpc_dynarray_rangecheck(p : pointer;i : tdynarrayindex) : tdynarrayindex;[Public,Alias:'FPC_DYNARRAY_RANGECHECK']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
|
begin
|
|
begin
|
|
if not(assigned(p)) or (i<0) or (i>pdynarray(p-sizeof(tdynarray))^.high) then
|
|
if not(assigned(p)) or (i<0) or (i>pdynarray(p-sizeof(tdynarray))^.high) then
|
|
@@ -58,8 +59,9 @@ function fpc_dynarray_high(p : pointer) : tdynarrayindex;[Public,Alias:'FPC_DYNA
|
|
fpc_dynarray_high:=-1;
|
|
fpc_dynarray_high:=-1;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+
|
|
{ releases and finalizes the data of a dyn. array and sets p to nil }
|
|
{ releases and finalizes the data of a dyn. array and sets p to nil }
|
|
-procedure fpc_dynarray_clear(var p : pointer;ti : pointer); [Public,Alias:'FPC_DYNARRAY_CLEAR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
|
|
|
|
|
+procedure fpc_dynarray_clear_internal(p : pointer;ti : pointer);
|
|
begin
|
|
begin
|
|
if p=nil then
|
|
if p=nil then
|
|
exit;
|
|
exit;
|
|
@@ -73,7 +75,13 @@ procedure fpc_dynarray_clear(var p : pointer;ti : pointer); [Public,Alias:'FPC_D
|
|
|
|
|
|
{ release the data }
|
|
{ release the data }
|
|
freemem(p);
|
|
freemem(p);
|
|
- p:=nil;
|
|
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+procedure fpc_dynarray_clear(var p : pointer;ti : pointer); [Public,Alias:'FPC_DYNARRAY_CLEAR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
|
|
|
+ begin
|
|
|
|
+ fpc_dynarray_clear_internal(p-sizeof(tdynarray),ti);
|
|
|
|
+ p:=nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
{$ifdef hascompilerproc}
|
|
{$ifdef hascompilerproc}
|
|
@@ -96,7 +104,7 @@ procedure fpc_dynarray_decr_ref(var p : pointer;ti : pointer);saveregisters;[Pub
|
|
{ decr. ref. count }
|
|
{ decr. ref. count }
|
|
{ should we remove the array? }
|
|
{ should we remove the array? }
|
|
if declocked(realp^.refcount) then
|
|
if declocked(realp^.refcount) then
|
|
- fpc_dynarray_clear(realp,pdynarraytypeinfo(ti));
|
|
|
|
|
|
+ fpc_dynarray_clear_internal(realp,pdynarraytypeinfo(ti));
|
|
p := nil;
|
|
p := nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -171,7 +179,7 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
|
|
{ if the new dimension is 0, we've to release all data }
|
|
{ if the new dimension is 0, we've to release all data }
|
|
if dims[dimcount-1]=0 then
|
|
if dims[dimcount-1]=0 then
|
|
begin
|
|
begin
|
|
- fpc_dynarray_clear(realp,pdynarraytypeinfo(pti));
|
|
|
|
|
|
+ fpc_dynarray_clear_internal(realp,pdynarraytypeinfo(pti));
|
|
p:=nil;
|
|
p:=nil;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
@@ -201,7 +209,7 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
|
|
{ if the array is now removed }
|
|
{ if the array is now removed }
|
|
{ fpc_dynarray_decr_ref(p,ti); }
|
|
{ fpc_dynarray_decr_ref(p,ti); }
|
|
if declocked(realp^.refcount) then
|
|
if declocked(realp^.refcount) then
|
|
- fpc_dynarray_clear(realp,pdynarraytypeinfo(ti));
|
|
|
|
|
|
+ fpc_dynarray_clear_internal(realp,pdynarraytypeinfo(ti));
|
|
end
|
|
end
|
|
else if dims[dimcount-1]<>realp^.high+1 then
|
|
else if dims[dimcount-1]<>realp^.high+1 then
|
|
begin
|
|
begin
|
|
@@ -302,7 +310,10 @@ procedure fpc_dynarray_copy(var pdest : pointer;psrc : pointer;ti : pointer;
|
|
|
|
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.24 2004-05-02 15:15:58 peter
|
|
|
|
|
|
+ Revision 1.25 2004-05-20 15:56:32 florian
|
|
|
|
+ * fixed <dyn. array>:=nil;
|
|
|
|
+
|
|
|
|
+ Revision 1.24 2004/05/02 15:15:58 peter
|
|
* use freemem() without size
|
|
* use freemem() without size
|
|
|
|
|
|
Revision 1.23 2003/10/29 21:00:34 peter
|
|
Revision 1.23 2003/10/29 21:00:34 peter
|