Ok im trying to sort commands by name. And the only thing it gives me is a
SIG_TRAP on the copyover. ok thats normal for gdb. and when the core does
finaly dump it gives me:

Segmentation fault (core dumped)
#0  0x400b1e47 in memcpy (dstpp=0x8151ad0, srcpp=0x10, len=3221218776) at
../sysdeps/generic/memcpy.c:55
55      ../sysdeps/generic/memcpy.c: No such file or directory.
        in ../sysdeps/generic/memcpy.c

so hrmm. no help there. my code:

int srt_cmds(const void *p1, const void *p2)
{
  struct cmd_type cmd1 = *(struct cmd_type *)p1;
  struct cmd_type cmd2 = *(struct cmd_type *)p2;

    logf("Made it here");
    if (cmd1.name == NULL) return 2;
    else
    if (cmd2.name == NULL) return 1;

    logf("Made it to the bottom");
  return ( strcmp( cmd1.name, cmd2.name ) );
}


void sort_commands(void)
{
 /* have to figure the # of commands first */
 int i;

 for (i=0; cmd_table[i].name != NULL && cmd_table[i].name[0] != '\0'; i++)

   if (cmd_table[i].name == NULL) break;

 logf("Size of command table: %d elements.", i);

 /* qsort command table */

 qsort((void *)cmd_table,
       i,
       sizeof(cmd_table[0]),
       srt_cmds);
}

i have a Rom24b6 mud. is there any other conversion i can use. qsort
should work. and its prolly the best sorter on linux. some reason in int
srt_cmds when it returns it dumps core. my log looks like:

Sun Feb 24 22:13:50 2002 :: Sun Feb 24 22:13:50 2002 :: Size of command
table: 357 elements.
Size of command table: 357 elements.
Sun Feb 24 22:13:50 2002 :: Sun Feb 24 22:13:50 2002 :: Made it here
Made it here
Sun Feb 24 22:13:50 2002 :: Sun Feb 24 22:13:50 2002 :: Made it to the
bottom
Made it to the bottom

End Of File

Uff blasted debugging!
I also have a social qsort function if anyone cares to have it drop me a
line. or email which ever.



Reply via email to