- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Elias,
aglMalloc() andaglMallocEx() actually create a shared memory object to store the array data. This allows other processes (e.g. the Array Viewer) to access the data without having to make a copy of the data each time the array is udpated. But as long as you pair aglMalloc() with aglFree() it should work ok.
aglReshape() should just change some header bytes in the memory allocated by aglMalloc(), it won't grow or shrink the memory. i.e. you can use aglReshape to change a one-dimensional 100 element array into a two-dimensional 10x10 element array. So I wouldn't think there could be any danger of aglReshape() corrupting the Delphi heap.
When you call aglReshape() are you sure that agl160.dll is getting a pointer to the first element of thedimensions array? And that Delphi is using 4-byte integers? AV won't hang on to the dimensions array pointer, so you're free to release it once the call completes.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
John-
I guess that the problem is that my Delphiprototype forthe aglReshape() call isn't correct,because a) Delphi uses 4-byte integers, and b) I'm pretty sure that I'm passing the dynamically-allocated array from Delphi properly. Hmm...
Actually, I'm less sure about part b. There's a bit of fiddling that needs to be done to get the address of the start of the data when dealing with Delphi dynamic arrays, since they're reference-counted, and the count is stored at the front of the object. You can't just pass a pointer to the array; you have to pass a pointer to the 0'th element. Perhaps I've screwed that up...
Anyway, thanks for the glimpse into the internals of the "agl" API.
Elias Sabbagh

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page