Solved

Pointers inside pointers

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

13 Experts available now in Live!

Get 1:1 Help Now