Solved

Pointers inside pointers

Posted on 2000-02-16
3
154 Views
Last Modified: 2010-04-04
 I have an app that uses an untyped pointer to a memory block up to >120MB. I want to divide it up into sub-blocks using other pointers, typed or untyped, which start at an arbitrary starting address (within the range of the original block), and have arbitrary sizes, (each of which will be less than the size of the original block).
  Damned if I know the solution.

Yours faithfully,
  HorridMan.
 
0
Comment
Question by:HorridMan
  • 2
3 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2530174
You can do it something like this:

var
  MainPtr : Pointer;
  HalfwayPtr : POinter;

GetMem(MainPtr, 120 * 1024 * 1024); // 120 Mb
HalfwayPtr := Pointer(Integer(MainPtr) + 60 * 1024 * 1024);

HalfwayPtr now points to the byte just after halfway (64Mb after MainPtr).

You can divide it any way you like...

Cheers,

Raymond.
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 2530176
Oops, meant that to be an answer
0
 
LVL 3

Expert Comment

by:sburck
ID: 2530179
For each memory block, assign a Tlist, which is an array of pointers.  Even better is a TStringList, where you can use the string portion of the list to put either a description of what your sub-pointer is pointing to, or a text version of the offset value (base pointer - sub pointer), so that if you need to save the memory block to disk, you can save the List as a text file, and then reload it and resurrect the pointers in the list from the text values.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 61
Delphi 2 45
Dev Express grid collapse 2 39
Moving (cutting/pasting) controls in a TTabbedNotebook... 7 27
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

948 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now