summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-29 13:26:58 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-29 13:26:58 +1300
commita3d54eabc331640c1f0a13ded5cbc4a7168f56da (patch)
tree51d0d1d8910135bd9cccfe52d7dffcc28e3264bd
parentMove command definitions back to .c file (diff)
downloadtexad-a3d54eabc331640c1f0a13ded5cbc4a7168f56da.tar.gz
texad-a3d54eabc331640c1f0a13ded5cbc4a7168f56da.zip
Adjust sizeof to use deref rather than indexingHEADmaster
-rw-r--r--texad.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/texad.c b/texad.c
index 7ba845d..91f75ba 100644
--- a/texad.c
+++ b/texad.c
@@ -26,10 +26,10 @@ struct world *genesis(void)
w = malloc(sizeof *w);
p = malloc(sizeof *p);
- for (i = 0; i < sizeof r / sizeof r[0]; i++)
- r[i] = malloc(sizeof r[0]);
- for (i = 0; i < sizeof d / sizeof d[0]; i++)
- d[i] = malloc(sizeof d[0]);
+ for (i = 0; i < sizeof r / sizeof *r; i++)
+ r[i] = malloc(sizeof *r);
+ for (i = 0; i < sizeof d / sizeof *d; i++)
+ d[i] = malloc(sizeof *d);
r[0]->title = "The foo room";
r[0]->description = "You are in the foo room. Sunlight streams from the windows.";
@@ -62,7 +62,7 @@ struct world *genesis(void)
{d[3], NULL, NULL}
};
- for (i = 0; i < sizeof r / sizeof r[0]; i++) {
+ for (i = 0; i < sizeof r / sizeof *r; i++) {
r[i]->doors = malloc(sizeof ds[i]);
memcpy(r[i]->doors, ds[i], sizeof ds[i]);
}
@@ -116,7 +116,7 @@ enum action parse(char *s)
{
unsigned long i;
s[strcspn(s, "\n")] = 0;
- for (i = 0; i < sizeof commands / sizeof commands[0]; i++)
+ for (i = 0; i < sizeof commands / sizeof *commands; i++)
if (commands[i].string && !strcmp(commands[i].string, s))
return commands[i].action;
return UNKNOWN;