This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

uint8 **record is increment by 16 byte

Other Parts Discussed in Thread: TMS570LS1224

Hi Friends,

Currently I am using TMS570ls1224;

I am getting some issue, 

uint8 **record;

record = malloc(sizeof(char)*4);
for(ilength = 0; ilength<4; ilength++)
{
record[ilength] = malloc(8);
}

when i am incementing 

record++;      // Here record is incementing by 16 byte instead of 8 byte

 

Thanks and Regards,

Arvind

  • This code sample is completely strange.
    What you want to have?
    First malloc is strange. You allocate sizeof(char)*4 = 4bytes, but you need to allocate sizeof(uint*)*4 = 16bytes.
    Last line with red comment increment pointer by pointer size (+4).
    What you want to do?
  • Sorry For such post,

    Here I attached screen shot of my debug window

    void EEPROM_DTCRead(uint8 len, uint8 **data)
    {
    uint8 ilen,index;
    uint8 DTC_Record[20][8] = {
    {'0','1','1','4','1','7','8','6'},{'0','2','1','4','1','7','8','6'},{'0','3','1','4','1','7','8','6'},{'0','4','1','4','1','7','8','6'},
    {1,0,14,4,16,7,8,6},{1,0,14,4,16,7,8,6},{1,0,14,4,16,7,8,6},{1,0,14,4,16,7,8,6},
    {1,1,14,4,16,7,8,6},{1,2,14,4,16,7,8,6},{1,3,14,4,16,7,8,6},{1,4,14,4,16,7,8,6},
    {2,1,14,4,16,7,8,6},{2,2,14,4,16,7,8,6},{2,3,14,4,16,7,8,6},{2,4,14,4,16,7,8,6},
    };

    for(index = 0; index<len; index++)
    {
    for(ilen = 0; ilen<8; ilen++)
    {
    data[index][ilen] = DTC_Record[index][ilen];
    }

    }
    }

    -> Here allocation of character not in contiguous (in memory browser window).

    Initially record is pointing to (0x08001520) memory location , and when record++ is executed it is pointing to (0x08001530).

    -> Here in this case record is increment by 16 byte but I want to increment it by 8 byte.

    Regards,

    Arvind .

     

  • I think what you want is DTC_Record[8][20], the first index is considered the row index and the second index the column.