home
·
contact
·
privacy
projects
/
plomrogue
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
651c99f
)
Removed unnecessary NULLings of pointers, explained kept ones.
author
Christian Heller
<c.heller@plomlompom.de>
Sat, 25 Jan 2014 19:13:19 +0000
(20:13 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Sat, 25 Jan 2014 19:13:19 +0000
(20:13 +0100)
src/client/command_db.c
patch
|
blob
|
history
src/client/draw_wins.c
patch
|
blob
|
history
src/client/io.c
patch
|
blob
|
history
src/client/main.c
patch
|
blob
|
history
src/client/misc.c
patch
|
blob
|
history
src/client/windows.c
patch
|
blob
|
history
src/server/init.c
patch
|
blob
|
history
src/server/io.c
patch
|
blob
|
history
src/server/map_objects.c
patch
|
blob
|
history
diff --git
a/src/client/command_db.c
b/src/client/command_db.c
index 7d35582dda258abb9472dcee87ce8bd7655d7e8d..159eb5836c71e46c5cd5402b33655907f8e7c2ae 100644
(file)
--- a/
src/client/command_db.c
+++ b/
src/client/command_db.c
@@
-73,10
+73,10
@@
extern void init_command_db()
copy_tokenized_string(line, &world.cmd_db.cmds[i].dsc_short, delim);
copy_tokenized_string(NULL, &world.cmd_db.cmds[i].server_msg, delim);
if (!strcmp("0", world.cmd_db.cmds[i].server_msg))
copy_tokenized_string(line, &world.cmd_db.cmds[i].dsc_short, delim);
copy_tokenized_string(NULL, &world.cmd_db.cmds[i].server_msg, delim);
if (!strcmp("0", world.cmd_db.cmds[i].server_msg))
- {
- free(world.cmd_db.cmds[i].server_msg);
- world.cmd_db.cmds[i].server_msg = NULL;
- }
+ {
/* .server_msg==0 detects */
+ free(world.cmd_db.cmds[i].server_msg);
/* non-server commands in */
+ world.cmd_db.cmds[i].server_msg = NULL;
/* control.h's try_key() / */
+ }
/* try_server_command(). */
char * arg_string = strtok(NULL, delim);
world.cmd_db.cmds[i].arg = arg_string[0];
copy_tokenized_string(NULL, &world.cmd_db.cmds[i].dsc_long, "\n");
char * arg_string = strtok(NULL, delim);
world.cmd_db.cmds[i].arg = arg_string[0];
copy_tokenized_string(NULL, &world.cmd_db.cmds[i].dsc_long, "\n");
diff --git
a/src/client/draw_wins.c
b/src/client/draw_wins.c
index 9fd78fc9088fdc1b419256dd10910bbca77b5513..54191f614832b1cf9428f97e1735158a64fc436d 100644
(file)
--- a/
src/client/draw_wins.c
+++ b/
src/client/draw_wins.c
@@
-358,12
+358,12
@@
extern void draw_win_inventory(struct Win * win)
win->center.y = world.player_inventory_select;
char inventory_copy[strlen(world.player_inventory) + 1];
sprintf(inventory_copy, "%s", world.player_inventory);
win->center.y = world.player_inventory_select;
char inventory_copy[strlen(world.player_inventory) + 1];
sprintf(inventory_copy, "%s", world.player_inventory);
- char *
foo
= inventory_copy;
+ char *
strtok_target
= inventory_copy;
uint8_t i = 0;
while (1)
{
uint8_t i = 0;
while (1)
{
- char * object = strtok(
foo
, "\n");
-
foo
= NULL;
+ char * object = strtok(
strtok_target
, "\n");
+
strtok_target
= NULL;
if (NULL == object)
{
return;
if (NULL == object)
{
return;
diff --git
a/src/client/io.c
b/src/client/io.c
index 095577d32e1d84fa0d68a89eb31d41a6ac5a76e1..4623b3d89bbe4e6aa1912c24b8acdec649637b34 100644
(file)
--- a/
src/client/io.c
+++ b/
src/client/io.c
@@
-5,6
+5,7
@@
#include <fcntl.h> /* open() */
#include <limits.h> /* PIPE_BUF */
#include <ncurses.h> /* halfdelay(), getch() */
#include <fcntl.h> /* open() */
#include <limits.h> /* PIPE_BUF */
#include <ncurses.h> /* halfdelay(), getch() */
+#include <stddef.h> /* NULL */
#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
#include <stdio.h> /* FILE, sprintf(), fseek() */
#include <string.h> /* strcmp(), strlen(), memcpy() */
#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
#include <stdio.h> /* FILE, sprintf(), fseek() */
#include <string.h> /* strcmp(), strlen(), memcpy() */
@@
-78,7
+79,7
@@
static void read_inventory(char * read_buf, uint32_t linemax, FILE * file)
char * f_name = "read_inventory()";
char * delimiter = "%\n";
free(world.player_inventory);
char * f_name = "read_inventory()";
char * delimiter = "%\n";
free(world.player_inventory);
- world.player_inventory = NULL;
+ world.player_inventory = NULL;
/* Avoids illegal strlen() below. */
while (1)
{
try_fgets(read_buf, linemax + 1, file, f_name);
while (1)
{
try_fgets(read_buf, linemax + 1, file, f_name);
diff --git
a/src/client/main.c
b/src/client/main.c
index 3e3bbdd28f7c6b6a83a2ac801d26caa2967eac92..2b6c18ad72f50284d6399431f6b5615c8f94c172 100644
(file)
--- a/
src/client/main.c
+++ b/
src/client/main.c
@@
-2,6
+2,7
@@
#include <ncurses.h> /* keypad() */
#include <signal.h> /* struct sigaction, sigaction() */
#include <ncurses.h> /* keypad() */
#include <signal.h> /* struct sigaction, sigaction() */
+#include <stddef.h> /* NULL */
#include <stdlib.h> /* exit() */
#include <string.h> /* memset() */
#include "../common/rexit.h" /* set_cleanup_func(), exit_trouble() */
#include <stdlib.h> /* exit() */
#include <string.h> /* memset() */
#include "../common/rexit.h" /* set_cleanup_func(), exit_trouble() */
diff --git
a/src/client/misc.c
b/src/client/misc.c
index ca8e829881077a947ac9ec9f64fed01808b031ad..839ce364afff19dee192aac1c0733b06a4b80c91 100644
(file)
--- a/
src/client/misc.c
+++ b/
src/client/misc.c
@@
-98,11
+98,8
@@
extern void load_interface_conf()
extern void unload_interface_conf()
{
free_keybindings(world.kb_global.kbs);
extern void unload_interface_conf()
{
free_keybindings(world.kb_global.kbs);
- world.kb_global.kbs = NULL;
free_keybindings(world.kb_wingeom.kbs);
free_keybindings(world.kb_wingeom.kbs);
- world.kb_wingeom.kbs = NULL;
free_keybindings(world.kb_winkeys.kbs);
free_keybindings(world.kb_winkeys.kbs);
- world.kb_winkeys.kbs = NULL;
while ('\0' != world.windb.active)
{
toggle_window(world.windb.active);
while ('\0' != world.windb.active)
{
toggle_window(world.windb.active);
diff --git
a/src/client/windows.c
b/src/client/windows.c
index 572fccd8811e9c68127336f0dd2609d8b26c915f..6bde9ef1ce2d5431e70bdabdb1680dd73038b320 100644
(file)
--- a/
src/client/windows.c
+++ b/
src/client/windows.c
@@
-483,8
+483,8
@@
static void draw_wins(struct Win * w)
w->start.x + (x - offset_x), ch);
}
}
w->start.x + (x - offset_x), ch);
}
}
- free(w->winmap);
- w->winmap = NULL;
+ free(w->winmap);
/* NULL so draw_wins.c's try_resize_winmap() may always */
+ w->winmap = NULL;
/* free() it before (re-)allocation, even the first time.*/
memset(&w->winmap_size, 0, sizeof(struct yx_uint16));
if (offset_y > 0)
{
memset(&w->winmap_size, 0, sizeof(struct yx_uint16));
if (offset_y > 0)
{
@@
-734,12
+734,10
@@
extern void free_windb()
free(wc->title);
free_keybindings(wc->kb.kbs);
}
free(wc->title);
free_keybindings(wc->kb.kbs);
}
- free(world.windb.ids);
- world.windb.ids = NULL;
+ free(world.windb.ids);
/* NULL this too since add_win_to_windb() checks */
+ world.windb.ids = NULL;
/* for it to detect its first post-DB-purge round.*/
free(world.windb.wins);
free(world.windb.wins);
- world.windb.wins = NULL;
free(world.windb.order);
free(world.windb.order);
- world.windb.order = NULL;
}
}
diff --git
a/src/server/init.c
b/src/server/init.c
index 1644cee35c3f3db6e08771cb7f8295b85dcfa9c5..97ed0fa09c0af955b835a2bd773436f4805255eb 100644
(file)
--- a/
src/server/init.c
+++ b/
src/server/init.c
@@
-49,15
+49,12
@@
extern void obey_argv(int argc, char * argv[])
extern void remake_world(uint32_t seed)
{
free(world.log);
extern void remake_world(uint32_t seed)
{
free(world.log);
- world.log = NULL;
+ world.log = NULL;
/* map_object_action.c's update_log() checks for this. */
world.seed = seed;
world.map_obj_count = 0;
world.score = 0;
free(world.map.cells);
world.seed = seed;
world.map_obj_count = 0;
world.score = 0;
free(world.map.cells);
- if (world.map_objs)
- {
- free_map_objects(world.map_objs);
- }
+ free_map_objects(world.map_objs);
world.last_update_turn = 0;
world.turn = 1;
init_map();
world.last_update_turn = 0;
world.turn = 1;
init_map();
diff --git
a/src/server/io.c
b/src/server/io.c
index 800f539aea747e53413f13d09fdc1cee7c823015..817d54253c40f69edc2225ef7f53e4769d15e78b 100644
(file)
--- a/
src/server/io.c
+++ b/
src/server/io.c
@@
-66,8
+66,8
@@
static char * get_message_from_queue()
world.queue_size = world.queue_size - cutout_len;
if (0 == world.queue_size)
{
world.queue_size = world.queue_size - cutout_len;
if (0 == world.queue_size)
{
- free(world.queue);
- world.queue = NULL;
+ free(world.queue);
/* NULL so read_fifo_into_queue() may free() this */
+ world.queue = NULL;
/* every time, even when it's un-allocated first. */
}
else
{
}
else
{
diff --git
a/src/server/map_objects.c
b/src/server/map_objects.c
index abcb6acfc35da8b10c64b942752ebe5c85e07a90..36fb9b79829d9667f2f984f361fe77d6a62d72e7 100644
(file)
--- a/
src/server/map_objects.c
+++ b/
src/server/map_objects.c
@@
-134,7
+134,6
@@
extern void free_map_object_defs(struct MapObjDef * mod_start)
free_map_object_defs(mod_start->next);
free(mod_start->name);
free(mod_start);
free_map_object_defs(mod_start->next);
free(mod_start->name);
free(mod_start);
- mod_start = NULL;
}
}
@@
-159,10
+158,10
@@
extern void free_map_objects(struct MapObj * mo_start)
free_map_objects(mo_start->owns);
free_map_objects(mo_start->next);
free(mo_start);
free_map_objects(mo_start->owns);
free_map_objects(mo_start->next);
free(mo_start);
- if (mo_start == world.map_objs)
- {
- world.map_objs = NULL;
- }
+ if (mo_start == world.map_objs)
/* So add_map_objects()' NULL-delimited */
+ {
/* map object iteration loop does not */
+ world.map_objs = NULL;
/* iterate over freed memory when called */
+ }
/* the 1st time after world re-seeding. */
}
}