commit - a966183f12546a7832602b3a25db7384660951d9fe66ee5d733de24ebf2665e6
commit + e06f726988f1ba79878783300e73db2564643823dd9d0ced9f28f098a1175e2d
blob - ef3a9db75044c6f7d79d6b6a0da8ef8a45000839bea8c622222e02e2a8c451df
blob + b10269e23efc106473df2aded5b2d4744c24f234ebed253756c66a0dce110521
--- lib/patch.c
+++ lib/patch.c
struct got_tree_object *tree = NULL;
char *fileindex_path = NULL;
char *oldpath, *newpath;
- struct imsgbuf *ibuf;
+ struct imsgbuf ibuf;
int imsg_fds[2] = {-1, -1};
int overlapcnt, done = 0, failed = 0;
pid_t pid;
- ibuf = calloc(1, sizeof(*ibuf));
- if (ibuf == NULL) {
- err = got_error_from_errno("calloc");
- goto done;
- }
+ memset(&ibuf, 0, sizeof(ibuf));
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1) {
err = got_error_from_errno("socketpair");
goto done;
}
imsg_fds[1] = -1;
- if (imsgbuf_init(ibuf, imsg_fds[0]) == -1) {
+ if (imsgbuf_init(&ibuf, imsg_fds[0]) == -1) {
err = got_error_from_errno("imsgbuf_init");
goto done;
}
- imsgbuf_allow_fdpass(ibuf);
+ imsgbuf_allow_fdpass(&ibuf);
- err = send_patch(ibuf, fd);
+ err = send_patch(&ibuf, fd);
fd = -1;
if (err)
goto done;
pa.progress_arg = progress_arg;
pa.head = &p.head;
- err = recv_patch(ibuf, &done, &p, strip);
+ err = recv_patch(&ibuf, &done, &p, strip);
if (err || done)
break;
got_object_commit_close(commit);
if (fd != -1 && close(fd) == -1 && err == NULL)
err = got_error_from_errno("close");
- if (ibuf != NULL) {
- imsgbuf_clear(ibuf);
- free(ibuf);
- }
+ if (ibuf.w)
+ imsgbuf_clear(&ibuf);
if (imsg_fds[0] != -1 && close(imsg_fds[0]) == -1 && err == NULL)
err = got_error_from_errno("close");
if (imsg_fds[1] != -1 && close(imsg_fds[1]) == -1 && err == NULL)