[Crossfire-wiki] [Crossfire DokuWiki] page changed: user:mhoram:code:bwp

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Thu Jan 18 21:34:12 CST 2007


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2007/01/18 21:34
User        : mhoram
Edit Summary: One bug left (I think)

@@ -28,8 +28,12 @@
  
  The way I read that, it looks like what I really want to pass to ''strcasecmp'' is a pointer to ''(char *)a'', but that doesn't work either.  (You can see that attempt commented out.)  I think for today I'm just going to comment out the ''qsort'' call so I can finish the rest of the program; in the meantime, any further hints on what I'm doing wrong would be much appreciated.
  
    * You need to do ''qsort(array->item, array->count, sizeof(char*), sortbyname);'', not ''qsort(array->item, array->count, array->longest, sortbyname);''. The item size is a char*, not the longest element. ''array->item'' is an array of ''char*'', that is of pointers to memory zones containing ''char'', not an array of items of size ''array->longest'' :) This can certainly explain some weird things.
+     * I see what you're saying, but I was calling it that way in my ''qsort'' of ''archnames'', and that was working ok.  ''archames'' is an array of arrays, though, while ''array->item'' is a pointer to an array of pointers, so I ssupose that's the difference.  In any case, I think I have everything else working, so I've updated the code below.  ''sortbyname'' now no longer causes segfaults, but it still isn't sorting correctly either.  To be exact, it sorts ''archnames'' correctly, but not ''array->item''.  When I try <code>*(const char* *)a</code>, it segfaults, and when I inspect the variables with gdb, it says that's accessing a bad address.  At this point, I'm really stumped on this part, but I'm still looking for other examples.
+ 
+ 
+ 
  
    * Also, to compare, try ''strcasecmp'' which does case-insensitive comparison.
      * That would be much easier, wouldn't it? :-)
  


IP-Address  : 206.71.197.56
Old Revision: http://wiki.metalforge.net/doku.php/user:mhoram:code:bwp?rev=1169176917
New Revision: http://wiki.metalforge.net/doku.php/user:mhoram:code:bwp

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list