0

I'm making a simple C chat-server chat. I need to pass two different arguments to a function called by a thread. I know that the only way to do this is to create a struct that contains both arguments but i have a simple int variable and a hashtable i created myself and i don't know how to copy the hashtable (already filled) in the struct. Here's the code of the hashtable:

hash_t CREATEHASH () {
  hash_t H;
  int i;
  H = (hash_t) malloc(HL*sizeof(list));
  for ( i=0; i < HL; i++ ) {
    H[i] = CREATELIST(); 
  }
  return H;
}

list CREATELIST () {
  list L;
  L = (list) malloc(sizeof (struct cell) ); 
  L->succ = L;
  L->pred = L;
  return L;
}

Someone can help me?

mc110
  • 2,833
  • 5
  • 21
  • 21
user3712139
  • 51
  • 2
  • 5
  • 3
    Why don't you pass a pointer to the hash table instead of copying it? That is, create a struct holding an integer and a pointer to the hash table. – Filipe Gonçalves Jun 05 '14 at 17:14
  • 1
    The question is tagged *sockets* and *threads* is is asking on how to use a `struct`? – alk Jun 05 '14 at 17:22
  • I tend to close this as being a duplicate to for example: http://stackoverflow.com/q/6524433/694576 – alk Jun 05 '14 at 17:43

0 Answers0