summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 095c424)
raw | patch | inline | side by side (parent: 095c424)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sat, 26 Aug 2006 14:16:18 +0000 (16:16 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 27 Aug 2006 00:54:06 +0000 (17:54 -0700) |
Change places that use realloc, without a proper error path, to instead use
xrealloc. Drop an erroneous error path in the daemon code that used errno
in the die message in favour of the simpler xrealloc.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
xrealloc. Drop an erroneous error path in the daemon code that used errno
in the die message in favour of the simpler xrealloc.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-fmt-merge-msg.c | patch | blob | history | |
builtin-log.c | patch | blob | history | |
builtin-mv.c | patch | blob | history | |
daemon.c | patch | blob | history | |
diff-delta.c | patch | blob | history | |
dir.c | patch | blob | history | |
git.c | patch | blob | history | |
sha1_file.c | patch | blob | history | |
xdiff-interface.c | patch | blob | history |
index 28b5dfd054ea8277379d6913b1f1c4cde225e70d..a5ed8dbbac2a1320e7cf61e16eeccdf5c5cee915 100644 (file)
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
{
if (list->nr == list->alloc) {
list->alloc += 32;
- list->list = realloc(list->list, sizeof(char *) * list->alloc);
- list->payload = realloc(list->payload,
+ list->list = xrealloc(list->list, sizeof(char *) * list->alloc);
+ list->payload = xrealloc(list->payload,
sizeof(char *) * list->alloc);
}
list->payload[list->nr] = payload;
diff --git a/builtin-log.c b/builtin-log.c
index 691cf3aef785950132c6be65f8aab39d4b12207e..fbc58bbcab1a992efb6ee359171d7ed6f0c52ab9 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
if (!strcmp(var, "format.headers")) {
int len = strlen(value);
extra_headers_size += len + 1;
- extra_headers = realloc(extra_headers, extra_headers_size);
+ extra_headers = xrealloc(extra_headers, extra_headers_size);
extra_headers[extra_headers_size - len - 1] = 0;
strcat(extra_headers, value);
return 0;
continue;
nr++;
- list = realloc(list, nr * sizeof(list[0]));
+ list = xrealloc(list, nr * sizeof(list[0]));
list[nr - 1] = commit;
}
total = nr;
diff --git a/builtin-mv.c b/builtin-mv.c
index fd1e52098174be212c51b957280f38dc6e9c0e48..4d21d88412cac52cbd5d127de439abc3e172b352 100644 (file)
--- a/builtin-mv.c
+++ b/builtin-mv.c
int j, dst_len;
if (last - first > 0) {
- source = realloc(source,
+ source = xrealloc(source,
(count + last - first)
* sizeof(char *));
- destination = realloc(destination,
+ destination = xrealloc(destination,
(count + last - first)
* sizeof(char *));
- modes = realloc(modes,
+ modes = xrealloc(modes,
(count + last - first)
* sizeof(enum update_mode));
}
diff --git a/daemon.c b/daemon.c
index 012936f3bd76d9f9648ba9498b4126c7d6861e5c..5bf5c82627beb8d8a5af71bce55c7e850ea54c46 100644 (file)
--- a/daemon.c
+++ b/daemon.c
for (ai = ai0; ai; ai = ai->ai_next) {
int sockfd;
- int *newlist;
sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sockfd < 0)
continue; /* not fatal */
}
- newlist = realloc(socklist, sizeof(int) * (socknum + 1));
- if (!newlist)
- die("memory allocation failed: %s", strerror(errno));
-
- socklist = newlist;
+ socklist = xrealloc(socklist, sizeof(int) * (socknum + 1));
socklist[socknum++] = sockfd;
if (maxfd < sockfd)
diff --git a/diff-delta.c b/diff-delta.c
index 51e2e561772f490eb59f534a62754993bba2a743..fa16d06c8d1e85a458428c673cb2f589857f5424 100644 (file)
--- a/diff-delta.c
+++ b/diff-delta.c
outsize = max_size + MAX_OP_SIZE + 1;
if (max_size && outpos > max_size)
break;
- out = realloc(out, outsize);
+ out = xrealloc(out, outsize);
if (!out) {
free(tmp);
return NULL;
index a686de660385f8991de2cb759b5994adca9e8b0f..d53d48f70c7f07a3fe5e6851467fc566b341aeb9 100644 (file)
--- a/dir.c
+++ b/dir.c
x->baselen = baselen;
if (which->nr == which->alloc) {
which->alloc = alloc_nr(which->alloc);
- which->excludes = realloc(which->excludes,
- which->alloc * sizeof(x));
+ which->excludes = xrealloc(which->excludes,
+ which->alloc * sizeof(x));
}
which->excludes[which->nr++] = x;
}
index a01d195c2319fd21fb361e535c5d6333550e3dbd..3adf262c41c3c8e86ab3e3c015e3febbc9a5c92f 100644 (file)
--- a/git.c
+++ b/git.c
; /* 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 == '"')) {
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;
diff --git a/sha1_file.c b/sha1_file.c
index dd9bcaabd0ea1a8c279f3da9297a53de9a8fc4cc..46272b591645e444396ae683673620594f336a7c 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
off += iret;
if (off == size) {
size *= 2;
- buf = realloc(buf, size);
+ buf = xrealloc(buf, size);
}
}
} while (iret > 0);
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 6a82da73b6d3b6b8cca23c3183cddc36c5cafb4b..08602f522183dc43787616f37cba9b8af4e3dade 100644 (file)
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
for (i = 0; i < nbuf; i++) {
if (mb[i].ptr[mb[i].size-1] != '\n') {
/* Incomplete line */
- priv->remainder = realloc(priv->remainder,
- priv->remainder_size +
- mb[i].size);
+ priv->remainder = xrealloc(priv->remainder,
+ priv->remainder_size +
+ mb[i].size);
memcpy(priv->remainder + priv->remainder_size,
mb[i].ptr, mb[i].size);
priv->remainder_size += mb[i].size;
consume_one(priv, mb[i].ptr, mb[i].size);
continue;
}
- priv->remainder = realloc(priv->remainder,
- priv->remainder_size +
- mb[i].size);
+ priv->remainder = xrealloc(priv->remainder,
+ priv->remainder_size +
+ mb[i].size);
memcpy(priv->remainder + priv->remainder_size,
mb[i].ptr, mb[i].size);
consume_one(priv, priv->remainder,