]> andersk Git - moira.git/commitdiff
Fix allocation strategy in setup_ahst(); shouldn't be redefining the argv
authortytso <tytso>
Fri, 10 Dec 1993 13:47:36 +0000 (13:47 +0000)
committertytso <tytso>
Fri, 10 Dec 1993 13:47:36 +0000 (13:47 +0000)
vector with newly allocated memory!  Also, don't try to get a new
machine id unless this is an add_host query.

Removed declaration for malloc, to support optional debugging malloc.

server/qsetup.dc

index d23e8d448a2519514bdf12f3ad188f98eb1b3469..450619fd81b02ce4755d3ee764147aeb22198514 100644 (file)
@@ -314,7 +314,6 @@ int setup_alis(q, argv, cl)
     EXEC SQL BEGIN DECLARE SECTION;
     int ngid;
     EXEC SQL END DECLARE SECTION;
-    char *malloc();
     unsigned char *p;
     int idx;
 
@@ -969,9 +968,9 @@ setup_ahst(q,argv,cl)
              value = htonl(value);
        }
        value = htonl(value);
-       argv[9+row] = strsave(inet_ntoa(value));
+       strcpy(argv[9+row], inet_ntoa(value));
     } else {
-       argv[9+row] = strsave("unassigned");
+       strcpy(argv[9+row], "unassigned");
     }
 
     /* status checking */
@@ -1016,13 +1015,20 @@ setup_ahst(q,argv,cl)
          return(MR_PERM);
     }
 
+    /*
+     * If this is an update_host query, we're done.
+     */
+    if (row == 1)
+       return(MR_SUCCESS);
+
+    /*
+     * For an add_host query, allocate and fill in a new machine id,
+     * and then insert the creator id.
+     */
     if ((mr_errcode = prefetch_value(q,argv,cl)) != MR_SUCCESS)
       return(mr_errcode);
 
-    row = q->argc + q->vcnt + 1;
-    sprintf(buf, "%d",cl->client_id);
-    argv[row] = strsave(buf);
-    argv[row+1] = NULL;
+    sprintf(argv[q->argc + q->vcnt + 1], "%d",cl->client_id);
     return(MR_SUCCESS);
 }
 
This page took 0.040166 seconds and 5 git commands to generate.