02-03-2019, 05:31 PM
Hi Gintaras, hi all,
i'd like to have some information to mimic linked lists in QM.
I replaced struct by type in QM
type Node int'nombre Node*suivant
type Liste Node*premier
Liste* Head=sub.Init
#sub Init
function'Liste*
Liste* liste=malloc(sizeof(Liste))
Node* element=malloc(sizeof(Node))
if(liste==0 or element==0) ret
element.nombre=0
element.suivant=0
liste.premier=element
ret liste
I'm quite bothered by two things:
1. In C, all pointers to struct are initialized to NULL for safety, and this does not exist in QM, so how
convert the QM declaration
2. are malloc, calloc and free used the same in QM and C? I ask this because i need to know how free memory safely.
Some other questions are in mind but i want to start with those.
Thanks
i'd like to have some information to mimic linked lists in QM.
I replaced struct by type in QM
type Node int'nombre Node*suivant
type Liste Node*premier
Liste* Head=sub.Init
#sub Init
function'Liste*
Liste* liste=malloc(sizeof(Liste))
Node* element=malloc(sizeof(Node))
if(liste==0 or element==0) ret
element.nombre=0
element.suivant=0
liste.premier=element
ret liste
I'm quite bothered by two things:
1. In C, all pointers to struct are initialized to NULL for safety, and this does not exist in QM, so how
convert the QM declaration
2. are malloc, calloc and free used the same in QM and C? I ask this because i need to know how free memory safely.
Some other questions are in mind but i want to start with those.
Thanks