On Sat, 1 Dec 2001, Daniel A. Koepke wrote: > How about: > > int create_entry(char *name) > { > . > . > . > } else if ((pos = get_ptable_by_name(name)) == -1) { /* new name */ > i = ++top_of_ptable + 1; > > RECREATE(player_table, struct player_index_element, i); > pos = top_of_p_table; > > /* > * Since the name is the same and already allocated for deleted > * players, we only CREATE and set for new names. > */ > CREATE(player_table[pos].name, char, strlen(name) + 1); > > /* copy lowercase equivalent of name to table field */ > for (i = 0; (player_table[pos].name[i] = LOWER(name[i])); i++) > /* Nothing */ ; > } > > return (pos); > } Nice, but we still need to copy the name into the table for existing entries, and in this case think it's much easier to just free the buffer and recreate it. Otherwise one have to check for enough space in the buffer and if it isn't, still free and recreate it. / Joachim ======================================================================= The Arrow http://pileborg.org/~arrow/ Joachim Pileborg Email: arrow@tpileborg.org ======================================================================= "Everyone wants to go to heaven, but no one wants to die" - Two Witches -- +---------------------------------------------------------------+ | 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 : 06/24/03 PDT