freebsd-ports/games/hangman/files/patch-src__dict.c
Marcus Alves Grando a8a78b7103 Challenge your spelling skills in the old western style. Get it
right and we'll let you try again, until you get it wrong. But we
will give you another chance if you get it wrong.

WWW: http://www.shiftygames.com/hangman/hangman.html

PR:		88767
Submitted by:	Dmitry Marakasov <amdmi3@mail.ru>
2005-11-11 15:31:49 +00:00

45 lines
1.2 KiB
C

--- src/dict.c.orig Sun Apr 11 01:22:40 2004
+++ src/dict.c Thu Nov 10 05:18:25 2005
@@ -84,11 +84,15 @@
****************************************************/
static void resize()
{
+ struct node *d;
+ struct node *t;
+ struct node ** old_table = dictionary;
unsigned int a;
+ size_t i;
size_t old_size = sizeOfTable;
- sizeOfTable *= 2;
numOfEntries = 0;
- struct node ** old_table = dictionary;
+
+ sizeOfTable *= 2;
dictionary = (struct node **)malloc(sizeof(struct node *) * sizeOfTable);
if(!dictionary) {
@@ -99,8 +103,9 @@
/* now copy old table into new table
and delete the old one */
- for(size_t i = 0; i < old_size; i++) {
- struct node * d = NULL, * t = old_table[i];
+ for(i = 0; i < old_size; i++) {
+ d = NULL;
+ t = old_table[i];
while(t) {
addToDictionary(t->word);
d = t;
@@ -157,10 +162,11 @@
{
FILE * input = NULL;
unsigned int a;
+ size_t i;
/* Delete the old dictionary if one exists */
if(dictionary) {
- for(size_t i = 0; i < sizeOfTable; i++) {
+ for(i = 0; i < sizeOfTable; i++) {
struct node * t = dictionary[i];
while(t) {
free(t->word);