*MyFile.h*
typedef char* dado_t;
typedef struct elemento elemento;
typedef struct lista2 lista2;
*MyFile.c*
struct elemento{
dado_t str;
elemento* ant;
elemento* prox;
};
struct lista2{
elemento* primeiro;
elemento* ultimo;
elemento* corrente;
};
void_insert(lista2* l, dado_t d){
elemento* novo = malloc(sizeof(elemento*));
novo->str = malloc(strlen(d) * sizeof(char));
novo->str = d;
l->corrente = novo;
l->primeiro = novo;
l->ultimo = novo;
novo->prox = NULL;
novo->ant = NULL;
}
dado_t replace(lista2* l, dado_t d){
dado_t retorno = malloc(strlen(corrente->str) * sizeof(dado_t));
retorno = corrente->str;
corrente->str = realloc(corrente->str, strlen(d) * sizeof(char));
l->corrente->str = d;
return retorno;
}
Why am I getting this error ? Since myel->str
is a pointer that has been allocated with malloc()
. Why the error ? I'm using an temporary element* to be prevented if an error happen with realloc()
Obs: