The Merciless Lord of Everything wrote: > char *to_vict = NULL, *to_room = NULL; > > Now, I remember having a discussion some time back with PjD about > this. And as far as I recall, this is a pointer which has "some" space in > it, but not very much (sorry, it's late and I should really be sleeping by > now :) if I recall corcretly it was assigned with 4 bytes or something in > that order. > The above line will not allocate any space for type char. what it does is it creates a pointer of type char and sets it to NULL, the only space allocated is that required for the pointer itself (which is implementation-defined). You would do the above if you wanted to either allocate your own space (with malloc or CREATE) and assign the p[ointer to it so you can keep track of it, or if you want to have an extra pointer that you can use to manipulate data in existing variables. > Okay, the messages in magic.c isn't really that big, and so this may not > cause any problem for those. But wouldn't it be more correct to do > something in the lines of > > char to_victim[MAX_STRING_LENGTH] = ""; > char to_char[MAX_STRING_LENGTH] = ""; > That all depends, if it has survived 6 bpls like this (and without double checking myself), I would imagine that it is correct as-is. The above will actually allocate space (of MAX_STRING_LENGTH chars) and create a variable which points to it. Note that unlike a pointer you cannot change what this variable points to, it is constant and will always point to the same area of memory. Regards, Peter +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT