{"thread":{"id":"7443","subject":"[PATCH] use xmalloc in diff-delta.c and removed NULL verification in builtin-pack-objects.c from create_delta_index()","startedAt":"2007-03-28T01:04:30Z","lastAt":"2007-03-28T03:03:53Z","messageCount":2,"participants":["Bruno Cesar Ribas"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38216","messageId":"20070328010430.GA8783@c3sl.ufpr.br","threadId":"7443","inReplyTo":null,"subject":"[PATCH] use xmalloc in diff-delta.c and removed NULL verification in builtin-pack-objects.c from create_delta_index()","fromName":"Bruno Cesar Ribas","fromEmail":"ribas@c3sl.ufpr.br","sentAt":"2007-03-28T01:04:30Z","receivedAt":"2007-03-28T01:04:30Z","isPatch":true,"sender":{"key":"ribas@c3sl.ufpr.br","avatar":null},"body":" builtin-pack-objects.c |    2 --\n diff-delta.c           |    8 ++------\n 2 files changed, 2 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex b5f9648..04a4abc 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -1254,8 +1254,6 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n        }\n        if (!src->index) {\n                src->index = create_delta_index(src->data, src_size);\n-               if (!src->index)\n-                       die(\"out of memory\");\n        }\n \n        delta_buf = create_delta(src->index, trg->data, trg_size, &delta_size, max_size);\ndiff --git a/diff-delta.c b/diff-delta.c\nindex 9f998d0..011d7d6 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -157,9 +157,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n        memsize = sizeof(*index) +\n                  sizeof(*hash) * hsize +\n                  sizeof(*entry) * entries;\n-       mem = malloc(memsize);\n-       if (!mem)\n-               return NULL;\n+       mem = xmalloc(memsize);\n        index = mem;\n        mem = index + 1;\n        hash = mem;\n@@ -258,9 +256,7 @@ create_delta(const struct delta_index *index,\n        outsize = 8192;\n        if (max_size && outsize >= max_size)\n                outsize = max_size + MAX_OP_SIZE + 1;\n-       out = malloc(outsize);\n-       if (!out)\n-               return NULL;\n+       out = xmalloc(outsize);\n \n        /* store reference buffer size */\n        i = index->src_size;\n-- \n1.5.0.3\n\n-- \nBruno Ribas - ribas@c3sl.ufpr.br\nhttp://web.inf.ufpr.br/ribas\nC3SL: http://www.c3sl.ufpr.br \n"},{"id":"38225","messageId":"20070328030353.GA654@c3sl.ufpr.br","threadId":"7443","inReplyTo":"20070328010430.GA8783@c3sl.ufpr.br","subject":"Re: [PATCH] use xmalloc in diff-delta.c and removed NULL verification in builtin-pack-objects.c from create_delta_index()","fromName":"Bruno Cesar Ribas","fromEmail":"ribas@c3sl.ufpr.br","sentAt":"2007-03-28T03:03:53Z","receivedAt":"2007-03-28T03:03:53Z","isPatch":true,"sender":{"key":"ribas@c3sl.ufpr.br","avatar":null},"body":"please ignore. Sending in right way.\n\nsorry.\n\nOn Tue, Mar 27, 2007 at 10:04:30PM -0300, Bruno Cesar Ribas wrote:\n>  builtin-pack-objects.c |    2 --\n>  diff-delta.c           |    8 ++------\n>  2 files changed, 2 insertions(+), 8 deletions(-)\n> \n> diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\n> index b5f9648..04a4abc 100644\n> --- a/builtin-pack-objects.c\n> +++ b/builtin-pack-objects.c\n> @@ -1254,8 +1254,6 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n>         }\n>         if (!src->index) {\n>                 src->index = create_delta_index(src->data, src_size);\n> -               if (!src->index)\n> -                       die(\"out of memory\");\n>         }\n>  \n>         delta_buf = create_delta(src->index, trg->data, trg_size, &delta_size, max_size);\n> diff --git a/diff-delta.c b/diff-delta.c\n> index 9f998d0..011d7d6 100644\n> --- a/diff-delta.c\n> +++ b/diff-delta.c\n> @@ -157,9 +157,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n>         memsize = sizeof(*index) +\n>                   sizeof(*hash) * hsize +\n>                   sizeof(*entry) * entries;\n> -       mem = malloc(memsize);\n> -       if (!mem)\n> -               return NULL;\n> +       mem = xmalloc(memsize);\n>         index = mem;\n>         mem = index + 1;\n>         hash = mem;\n> @@ -258,9 +256,7 @@ create_delta(const struct delta_index *index,\n>         outsize = 8192;\n>         if (max_size && outsize >= max_size)\n>                 outsize = max_size + MAX_OP_SIZE + 1;\n> -       out = malloc(outsize);\n> -       if (!out)\n> -               return NULL;\n> +       out = xmalloc(outsize);\n>  \n>         /* store reference buffer size */\n>         i = index->src_size;\n> -- \n> 1.5.0.3\n> \n> -- \n> Bruno Ribas - ribas@c3sl.ufpr.br\n> http://web.inf.ufpr.br/ribas\n> C3SL: http://www.c3sl.ufpr.br \n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n-- \nBruno Ribas - ribas@c3sl.ufpr.br\nhttp://web.inf.ufpr.br/ribas\nC3SL: http://www.c3sl.ufpr.br \n"}]}