[CODE][NEWBIE] sedit_add_to_int_list()

From: Christopher J. Bottaro (cjb9@mail.utexas.edu)
Date: 05/15/99


it seems this function does not do anything at all.  i've determined that it >does< get called, but after it is called, nothing is different.  the call looks like this:  sedit_add_to_int_list(&(S_PRODUCTS(OLC_SHOP(d))), i);
everything seems right, passes the address of the int pointer "producing", i is the number to add.  i wonder why it doesn't change anything.

also, sedit_remove_from_int_list() seems to crash the program altogether...=(

thank you.

void sedit_add_to_int_list(int **list, int new_item)
{
  int i, num_items, *nlist;

  /*
   * Count number of entries.
   */
  for (i = 0; (*list)[i] != -1; i++);
  num_items = i;

  /*
   * Make a new list and slot in the new entry.
   */
  CREATE(nlist, int, num_items + 2);

  for (i = 0; i < num_items; i++)
    nlist[i] = (*list)[i];
  nlist[num_items] = new_item;
  nlist[num_items + 1] = -1;

  /*
   * Out with the old, in with the new.
   */
  free(*list);
  *list = nlist;
}


     +------------------------------------------------------------+
     | 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 : 12/15/00 PST