Hi,

I have just started getting my head around C programming. At some point of my program, I have:

Code:
 
...
    max_basket = 0;
    for (i = 0; i< num_threads; i++) {
            LONG opt_basket_abs_cost = opt_basket[i]->abs_cost;
            LONG max_basket_abs_cost = max_basket->abs_cost;
            int  opt_basket_a_id = opt_basket[i]->a->id;
            int  max_basket_a_id = max_basket->a->id;


    if ((!max_basket && opt_basket[i]) || (opt_basket[i] && cost_compare(opt_basket_abs_cost, max_basket_abs_cost, opt_basket_a_id, max_basket_a_id) < 0)) {
        max_basket = opt_basket[i];
      }
    }
...
I have to pass values rather than pointers to the function "cost_compare". And here is definitions:
Code:
...
              BASKET*           max_basket;
static     BASKET        *basket;
static     BASKET        **opt_basket;
...
typedef struct basket
{
    arc_t *a;
    cost_t cost;
    cost_t abs_cost;
    LONG number;
} BASKET;
...
struct arc
{
  int id;
  cost_t cost;
  node_p tail, head;
  short ident;
  arc_p nextout, nextin;
  flow_t flow;
  cost_t org_cost;
} ;
But when I compile (eclipse IDE), I get

Code:
Program received signal SIGSEGV, Segmentation fault.
0x0000555555559e85 in master (net=0x55555575d0a0 <net>, num_threads=1) at ../src/psimplex.c:195
195                       LONG max_basket_abs_cost = max_basket->abs_cost;


Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
I appreciate if someone can give me a hint how to fix this without altering function's parameeters.

Regards
Hooman