Announcement

Collapse
No announcement yet.

Array memory allocation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Array memory allocation

    I'm using a DLL function that accepts an integer array from VB, does some
    hardware I/O, modifies the VB array and exits. I'm passing the VB array
    as outlined in Appendix A of the PB manual, so that should be okay. The
    trouble is that the PB DLL function needs to allocate an integer array for
    temporary use with the I/O driver; how can I be sure that the local array
    memory won't conflict with the passed VB array?

    The hardware I/O driver has a debug mode that shows the memory addresses
    of the arrays passed to it, and it appears that there is a memory
    overlap. If true, I could pass all of the needed arrays from VB to PB, but
    that would really gum up the VB code (more than it already is ).

    Any ideas?


    ------------------
    Mark Newman
    Mark Newman

  • #2
    Arrays allocated in PB will never overlap with arrays allocated in VB, unless you specifically use the DIM..AT syntax to override this behavior.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment


    • #3
      Tom,

      Thanks for the reply; this is the behavior that I would expect.
      I'll keep digging!



      ------------------
      Mark Newman
      Mark Newman

      Comment


      • #4
        ...um, found it...

        I was passing the I/O driver the addresses of the array pointers,
        not the addresses of the arrays themselves. Using BYVAL VARPTR(array(0))
        instead of VARPTR(array(0)) did the trick.

        As a lame defense of this "oversight" I'll add that I was porting
        the function declares and function stubs from a VB file to PB
        format. Yes, that's it, I'll blame the sometimes-bizarre VB-to-DLL
        calling convention...



        ------------------
        Mark Newman
        Mark Newman

        Comment

        Working...
        X