'movable pointer does not point to its initial object' Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

'movable pointer does not point to its initial object'

Post by DemoniacMilk »

So i tested some more, minimalistic program i came up with is (removed any addittional integrity checks etc)

Code: Select all

void configFpga(client spi_master_async_if spi_if) {
    char * movable txbuf;
    char * movable rxbuf;
    char * flashPage;
    unsigned *ptr;
    unsigned remainToSend = 5000;
    unsigned fpgaConfigReadPageNumber = 1;

    fl_connectToDevice(flashPorts, flashDevices, FLASH_NUM_DEVICES);
    pageSize = fl_getPageSize();

    txbuf = malloc(pageSize);
    rxbuf = malloc(pageSize);
    flashPage = malloc(pageSize);

    fl_readDataPage(fpgaConfigReadPageNumber, flashPage))
    memcpy(txbuf, flashPage, pageSize);

    [...]
    // loop: send data via SPI Master, meanwhile read more data into flashPage using libflash
    // retrieve buffers when SPI Master has finished the transaction
    // memcpy flashPage to txbuf as above, loop more data is available

     free(flashPage);
    // free(rxbuf); free(txbuf); //<-- needed or not needed?
}
With this approach, the program traps at the end of the function: movable pointer 'rxbuf' does not point to its initial object when going out of scope. May i not use movable pointers with malloc? That'd be surprising, as malloc returns a movable pointer. What am I missing here?


View Solution
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

Code: Select all

    free(rxbuf);
    free(txbuf);
    rxbuf = NULL;
    txbuf = NULL;
Nulling the pointers at the end did the trick.