Use xmalloc instead of malloc
[gitweb.git] / git.c
diff --git a/git.c b/git.c
index 96e596b1a385266a5c0e0638b0e682b06c55c506..05871ad42c8c20999e2dd977ea6033f38614e862 100644 (file)
--- a/git.c
+++ b/git.c
@@ -29,7 +29,7 @@ static void prepend_to_path(const char *dir, int len)
 
        path_len = len + strlen(old_path) + 1;
 
-       path = malloc(path_len + 1);
+       path = xmalloc(path_len + 1);
 
        memcpy(path, dir, len);
        path[len] = ':';
@@ -92,7 +92,7 @@ static int handle_options(const char*** argv, int* argc)
 }
 
 static const char *alias_command;
-static char *alias_string = NULL;
+static char *alias_string;
 
 static int git_alias_config(const char *var, const char *value)
 {
@@ -120,7 +120,7 @@ static int split_cmdline(char *cmdline, const char ***argv)
                                ; /* skip */
                        if (count >= size) {
                                size += 16;
-                               *argv = realloc(*argv, sizeof(char*) * size);
+                               *argv = xrealloc(*argv, sizeof(char*) * size);
                        }
                        (*argv)[count++] = cmdline + dst;
                } else if(!quoted && (c == '\'' || c == '"')) {
@@ -191,8 +191,8 @@ static int handle_alias(int *argcp, const char ***argv)
                        fflush(stderr);
                }
 
-               new_argv = realloc(new_argv, sizeof(char*) *
-                                  (count + *argcp + 1));
+               new_argv = xrealloc(new_argv, sizeof(char*) *
+                                   (count + *argcp + 1));
                /* insert after command name */
                memcpy(new_argv + count, *argv + 1, sizeof(char*) * *argcp);
                new_argv[count+*argcp] = NULL;
@@ -252,7 +252,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
                { "pack-objects", cmd_pack_objects, RUN_SETUP },
                { "prune", cmd_prune, RUN_SETUP },
                { "prune-packed", cmd_prune_packed, RUN_SETUP },
-               { "push", cmd_push },
+               { "push", cmd_push, RUN_SETUP },
                { "read-tree", cmd_read_tree, RUN_SETUP },
                { "repo-config", cmd_repo_config },
                { "rev-list", cmd_rev_list, RUN_SETUP },
@@ -263,6 +263,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
                { "stripspace", cmd_stripspace },
                { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
                { "tar-tree", cmd_tar_tree, RUN_SETUP },
+               { "zip-tree", cmd_zip_tree, RUN_SETUP },
                { "unpack-objects", cmd_unpack_objects, RUN_SETUP },
                { "update-index", cmd_update_index, RUN_SETUP },
                { "update-ref", cmd_update_ref, RUN_SETUP },
@@ -270,6 +271,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
                { "version", cmd_version },
                { "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
                { "write-tree", cmd_write_tree, RUN_SETUP },
+               { "verify-pack", cmd_verify_pack },
        };
        int i;
 
@@ -291,11 +293,11 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
                if (p->option & USE_PAGER)
                        setup_pager();
                if (getenv("GIT_TRACE")) {
-                       int i;
+                       int j;
                        fprintf(stderr, "trace: built-in: git");
-                       for (i = 0; i < argc; ++i) {
+                       for (j = 0; j < argc; ++j) {
                                fputc(' ', stderr);
-                               sq_quote_print(stderr, argv[i]);
+                               sq_quote_print(stderr, argv[j]);
                        }
                        putc('\n', stderr);
                        fflush(stderr);