Re: Curious question for act.comm.c

From: Carlos Myers (farix@stargate.net)
Date: 09/01/01


From: "Del" <caminturn@earthlink.net>
> Carlos Myers wrote:
> >
> > > Mike Breuer wrote:
> > > >
> > > >  ACMD(do_write)
> > > >  {
> > > >    struct obj_data *paper, *pen = NULL;
> > > > -  char *papername, *penname;
> > > > +  char papername[MAX_STRING_LENGTH], penname[MAX_STRING_LENGTH];
> > > >
> > > > -  papername = buf1;
> > > > -  penname = buf2;
> > > >
> >
> > But two_arguments does not create a new string.  It uses the existing
> > strings that were passed to it.  So if you pass it a NULL, two_arguments
> > will reformat your harddrive, corrupt you BIOS and finally blow your
house
> > up.  Well maybe not, but you will get some sort of error.
>
> Ok.. It must be the beginning of a long weekend!
> I think Mike was right. But I think MAX_STRING_LENGTH is a little large
> for this purpose. Would not MAX_INPUT_LENGTH be better?

Mike's changes makes things less confusion since they change the pointers to
the global buffers to actual strings.  But when you call two_arguments you
are passing pointers to the strings and not the strings themselves.

Carlos

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/06/01 PST