Solved

Data Structures | Follow Up

Posted on 2004-08-01
1
207 Views
Last Modified: 2010-04-05
Q is follow up of http:Q_21077801.html

Detailing a bit of Dynamic Arrays and how to get the size of them plus some tips and tricks...
0
Comment
Question by:Cerf
1 Comment
 
LVL 34

Accepted Solution

by:
Slick812 earned 250 total points
ID: 11690698
I will guess that you need the sizeOf for some kind of memory copy of array data?
if you have used fixed arrays you can get the array Data by the array variable's pointer address

var
aryFixed: TPMem51;

begin
CopyMemoy(@aryFixed, pPointer, SizeOf(aryFixed));
 - - - - - - - - -

but this will NOT work with dynamic arrays because the variable is jus a pointer to a delphi reference that handles the dynamic array, to use a pointer location for a dynamic arrat, I use the address of the first element

var
 _tData: Array of Word;

begin
// setlength and whatever
 pData := @_tData[0]; // first element of array for memory address od the array data


however, a SizeOf( ) for ANY TObject, or dynamic array (a String type is a dynamic array) it will ALWAYS return 4 , because these Objects and dynamic arrays are Pointers, because objects and dyn arrays are ReAllocated memory blocks,
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question