/* move a node from it's old position to it's new position during a rehash; first, check whether the moving node's main position is free. If not, check whether colliding node is in its main position or not: if it is not, move colliding node to an empty place and put moving node in its main position; otherwise (colliding node is in its main position), moving node goes to an empty position.  */
static int move_node(lua_State *L, Table *t, Node *node)
/* move a node from it's old position to it's new position during a rehash; first, check whether the moving node's main position is free. If not, check whether colliding node is in its main position or not: if it is not, move colliding node to an empty place and put moving node in its main position; otherwise (colliding node is in its main position), moving node goes to an empty position.  */
static int move_node(lua_State *L, Table *t, Node *node)
{
    Node *othermp;
    othermp = mainposition(t, key2tval(mp));
    if (othermp != mp) {
      Node *prev;
      Node tmp;
      tmp = *node;
      prev = find_prev_node(othermp, mp);
      if (prev != NULL) gnext(prev) = node;
      *node = *mp;
      *mp = tmp;
      return (prev != NULL) ? 1 : 0;
    }
    else {
      gnext(node) = gnext(mp);
      gnext(mp) = node;
    }
  }
  else {
    *mp = *node;
    gnext(node) = NULL;
    setnilvalue(gkey(node));
    setnilvalue(gval(node));
  }
  return 1;
}