commit - ad3f6569ebcf5e03dcdb20e07b0339a8429388b8
commit + 7a9b1c13f55a6aa3392ccc4a59ba7dc278c2683a
blob - 6585749c44d27fcfe5870429cad2f6748af20bc4
blob + edb26e01b7ce7ae6f0582ad4b4cb1a56c500e3d4
--- 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)