]> git.pond.sub.org Git - empserver/commitdiff
(sona): Simplify the memory allocation for rad[] and vis[].
authorRon Koenderink <rkoenderink@yahoo.ca>
Sat, 14 Jan 2006 15:50:16 +0000 (15:50 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sat, 14 Jan 2006 15:50:16 +0000 (15:50 +0000)
No functional changes.

src/lib/commands/sona.c

index 8b3f30110cf199a838931becb672dc5cf0a39daf..8103cc49d790727ee17aae9a1b42309ae4f0486b 100644 (file)
@@ -85,26 +85,20 @@ sona(void)
        radbuf = malloc((WORLD_Y * (WORLD_X + 1)));
     if (!visbuf)
        visbuf = malloc((WORLD_Y * (WORLD_X + 1)));
-    if (!rad) {
+    if (!rad && radbuf) {
        rad = malloc(WORLD_Y * sizeof(char *));
-       if (rad && radbuf) {
+       if (rad) {
            for (x = 0; x < WORLD_Y; x++) {
                rad[x] = &radbuf[(WORLD_X + 1) * x];
            }
-       } else if (rad) {
-           free(rad);
-           rad = NULL;
        }
     }
-    if (!vis) {
+    if (!vis && visbuf) {
        vis = malloc(WORLD_Y * sizeof(char *));
-       if (vis && visbuf) {
+       if (vis) {
            for (x = 0; x < WORLD_Y; x++) {
                vis[x] = &visbuf[(WORLD_X + 1) * x];
            }
-       } else if (vis) {
-           free(vis);
-           vis = NULL;
        }
     }
     if (!radbuf || !visbuf || !rad || !vis) {