Vector memory allocation of int inside a struct

Asked

Viewed 32 times

0

My structures are defined this way:

typedef struct{
    Medicoes *medi;
    unsigned int numeroMots;//comprimento de mots diferentes, nao repete
    int *mots;//MOTS existentes na room
    int compMots;//omprimento do vetor MOTS, pode ter mots iguais
    char **ActuadorName;
    unsigned int countActuador;
    unsigned int *ActuadorOnOff;// 1 se tiver on, 0 se tiver off. Segue o mesmo indice que actuadorName
} Sensores;

typedef struct{
    Sensores *roomName;
    unsigned int countRoom;

} Room;    

When making the memory allocation I get a warning from "Cannot find Bounds of Current Function" My allocation is as follows, where it is in a cycle for:

room->roomName[i].mots=NULL;
room->roomName[i].mots= realloc(room->roomName[i].mots, sizeof(int *) * (vec->elementos[i].CountMots));

Everything is well defined, vec->elementos[i].CountMots contains the number 3 as for example, I already checked everything in debug mode and receives the correct values.

Is the allocation done correctly? Does anyone have an idea of what’s going on?

  • roomName is just a pointer to a Sensors structure. You need to point this pointer at a memory area before using it (preferably an area that has a sensor-like structure).

  • If using my code as an example to answer would be very good, because I’m having trouble with that

  • paste here the error lines that were shown...should have more information there...including why the message you put here doesn’t seem to make sense: "Cannot find Bounds of Current Function"

  • When I run the program there is no error, only it gives this error when I debug the program. Not an error or compilation warning, just don’t let me advance on debug and give this warning

  • With the information posted I think we can not know what is causing the problem...in Stackoverflow English however there are questions on the subject: here and here for example, maybe they can help

  • Because I understand, I’ll close the question. .

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.