Solved

Pointers inside pointers

Posted on 2000-02-16
3
155 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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