Christian Biesinger wrote: >> char *entry = "foobar" + '\0'; > > I'm puzzled why you are doing a + '\0' here... all string literals have > a terminating NUL in C and C++, and + does not do what you seem to think > with char*.
Thanks for telling. As you can see from my the rest of the code, I'm not really used to pointers and memory management. I'm coming from the 'scripting side' :-) >> *newcount = i; > > This is where you were crashing, because you carefully inited newcount > to be a NULL pointer. True, I found out minutes after I posted, but thought this wouldn't be the reason for the crash. I have a very ugly version which runs through (not using *entry but initializing with "foo" directly, and setting count to 3) - and stripped the posted code from there. That's a NULL pointer because 'i' will get out of scope at the end of 'for' if I understand correctly *blushing*. >> I've read about ADDREF, > Not an issue here since no objects are passed anywhere. I guessed so. - but wasn't too sure - my skillset didn't permit :-) > compiler took the liberty of optimizing away that variable entirely, > maybe? (since *count is effectively unchanged by your code) Nope. You're right, it crashed. I'm using gcc/++ 3.3.3, not that silver-bullet-compiler they talk about in ads ;-) >> And I've read about using the event-queue and callbacks for such >> communication, but would prefer the above approach if possible. > > If you are not using threads, you need not bother with event queues, > most likely. Thanks Christian. You've been a great help and source of knowledge. Your response is extremely appreciated and the component works fine now. _______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
