[Crossfire-wiki] [Crossfire DokuWiki] page changed: user:mhoram:code:bwp
no-reply_wiki at metalforge.org
no-reply_wiki at metalforge.org
Wed Jan 17 10:46:30 CST 2007
A page in your DokuWiki was added or changed. Here are the details:
Date : 2007/01/17 10:46
User : mhoram
Edit Summary: thanks for the help!
@@ -6,11 +6,21 @@
Also, if anyone knows of a good C primer/tutorial online, please let me know.
* In the sortbyname, a and b will be const char* *, not char*, thus you need to dereference them => ''strcpy(aa,(*(const char* *)a));'' or something like that :)
+ * I've stared at this for a while, and found some examples that do it, and I think I'm starting to understand it. I still don't quite see how the arguments can be char* *, when the function defines them as const void *, but I'll get there.
+ * I changed it to the example you gave, and now it segfaults on that strcpy. ;-) I think I'm on the right track now, though. It makes sense that the problem was in that comparison routine, since I checked the addresses of the variables within join_with_comma, and none of them were even close to the ones that were getting mangled.
+
* Also, to compare, try ''strcasecmp'' which does case-insensitive comparison.
+ * That would be much easier, wouldn't it? :-)
+
* ''append_with_comma'' (not used, but just in case) has a side effect: old will be destroyed if not NULL - the ''realloc'' can make the original pointer (which still exists probably) point to a freed memory.
+ * That function got replaced by join_with_comma and will be deleted anyway, but I should understand this. Isn't the whole point of realloc that it leaves the data pointed to unchanged?
+
* and some day don't forget to ''free()'' allocated memory (for the char* and such) ^_-
+ * Yes, I figured I'd need to do that, but I'm still learning just what I have to free. Anything I allocated manually, I assume, but I get a little hazy on it when something was allocated in a subroutine.
+
+ Thanks for all your help!
===== Notes & Comments =====
IP-Address : 206.71.197.56
Old Revision: http://wiki.metalforge.net/doku.php/user:mhoram:code:bwp?rev=1169040243
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