Hi, everyone:
I'm reading the source code of NS. I'm really
bewildered by some codes. Here is an example (from agent.cc)
Agent::~Agent()
{ if (oldValueList_ != NULL) { OldValue *p; // dynamic variable, not initialized while (oldValueList_ != NULL) { oldValueList_ = oldValueList_->next_; delete p; // does it work for the first element?????? p = oldValueList_; } } } Obviously the intention of the destructior is to
delete all the element in the list. But the first element will never be
deleted because p has not been initialized.
Another example (from DSDV_agent):
int DSDV_Agent::command (int argc, const char
*const *argv)
{ if (argc == 2) { if (strcmp (argv[1], "start-dsdv") == 0) {
..........................
} else if (strcmp (argv[1], "dumprtab") == 0) { .............................
}
else if (strcasecmp (argv[1], "ll-queue") ==
0)
{ if (!(ll_queue = (PriQueue *) TclObject::lookup (argv[2]))) // ?????????????????? { fprintf (stderr, "DSDV_Agent: ll-queue lookup of %s failed\n", argv[2]); return TCL_ERROR; }
return TCL_OK;
} }
else if (argc == 3) {
..........................................
} return (Agent::command (argc, argv)); } in the line
if
(!(ll_queue = (PriQueue *) TclObject::lookup (argv[2])))
what is the vaule in argv[2] since it has
only two arguments. ??????????
Are they bugs ?
HE Jun
|