Solved

Pointers inside pointers

Posted on 2000-02-16
3
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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