Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2018, 07:05 AM
comer1 comer1 is offline
Junior Member
 
Join Date: Dec 2011
Posts: 13
Default allocate contiguous block

Is it possible to make delphi allocate contiguous block of a memory?

I have a dynamically allocated array filled with data, pointer to which has to passed to an API function(It prefer to be an API).

The problem is, SetLenght (also GetMem) sometimes allocate the array over the two memory pages which makes the API fail.

The block is just over 200kb nothing huge.


I prefer the memory block to be an array since generating its content with help of an indexing is very convenient as opposed to work with pointers.
Reply With Quote
  #2  
Old 05-08-2018, 06:59 PM
comer1 comer1 is offline
Junior Member
 
Join Date: Dec 2011
Posts: 13
Default

nevermind I've found a way
Reply With Quote
  #3  
Old 05-12-2018, 04:12 PM
Ouiji Ouiji is offline
Senior Member
 
Join Date: Nov 2001
Location: US of A
Posts: 492
Default

If you have a spare moment to post the solution you found, it helps to boost the knowledge which resides here, and it may come in handy for another user down the road. =)
__________________
"not quite smart enough to be dumb"
Extended Stats No Longer Available Due To Changes To The Forum.
Reply With Quote
  #4  
Old 05-24-2018, 05:50 PM
comer1 comer1 is offline
Junior Member
 
Join Date: Dec 2011
Posts: 13
Default

I did not expect anybody to take interest in my problem,
since is quite specific and involving API functions.

I conveniently used dynamic array to all the changes then moved this memory to VirtualAlloc allocated space(which is contiguous).

That's all.

Lesson I got from this. Do not try to use memory allocated with delphi functions with API functions, only delphi knows how to access it properly.

Last edited by comer1; 05-24-2018 at 05:55 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:48 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.