Solved

Pointers inside pointers

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 161
Show Listview image from database (String field) 5 138
Dev Express grid collapse 2 45
Typecasting TBytes to Integer in Delphi XE8 2 10
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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