typedef struct _DocumentRow
{
char * code /** The code */;
char * designation /** The designation */;
double quantity /** The quantity */;
char * unity /** The unity */;
double basePrice /** The base price */;
double sellingPrice /** The selling price */;
double discount /** The discount */;
double rateOfVAT /** The rate of VAT */;
struct _DocumentRow * next /** The pointer to the next row */;
} DocumentRow;
void DocumentRowList_init(DocumentRow ** list) {
DocumentRow *L;
list = ( DocumentRow ** ) malloc( sizeof( DocumentRow* ) );
if ( list == NULL ) {
fatalError( "memory is not enough" );
}
L = NULL;
list = &L;
}
After using the function DocumentRowList_init, when I test if ( *list == NULL ), it evaluates to false, why ? I have already set list = &L and L = NULL.
listis local.*list = L;to set.L = NULL; list = &L;?!L = malloc( sizeof( DocumentRow ) );if(L == NULL) ...listand then you makelistto point somewhere else. You will not be able tofree(list). And*listis notNULLbecause*listisLwhich is a pointer toNULL. Outside this function, testing*listmay result in a segmentation fault.