##// END OF EJS Templates
chg: use mallocx and reallocx in hgclient...
Jun Wu -
r28166:c6e0c253 default
parent child Browse files
Show More
@@ -84,10 +84,7 b' static void enlargecontext(context_t *ct'
84
84
85 newsize = defaultdatasize
85 newsize = defaultdatasize
86 * ((newsize + defaultdatasize - 1) / defaultdatasize);
86 * ((newsize + defaultdatasize - 1) / defaultdatasize);
87 char *p = realloc(ctx->data, newsize);
87 ctx->data = reallocx(ctx->data, newsize);
88 if (!p)
89 abortmsg("failed to allocate buffer");
90 ctx->data = p;
91 ctx->maxdatasize = newsize;
88 ctx->maxdatasize = newsize;
92 debugmsg("enlarge context buffer to %zu", ctx->maxdatasize);
89 debugmsg("enlarge context buffer to %zu", ctx->maxdatasize);
93 }
90 }
@@ -195,9 +192,7 b' static const char **unpackcmdargsnul(con'
195 for (;;) {
192 for (;;) {
196 if (nargs + 1 >= maxnargs) { /* including last NULL */
193 if (nargs + 1 >= maxnargs) { /* including last NULL */
197 maxnargs += 256;
194 maxnargs += 256;
198 args = realloc(args, maxnargs * sizeof(args[0]));
195 args = reallocx(args, maxnargs * sizeof(args[0]));
199 if (!args)
200 abortmsg("failed to allocate args buffer");
201 }
196 }
202 args[nargs] = s;
197 args[nargs] = s;
203 nargs++;
198 nargs++;
@@ -432,9 +427,7 b' hgclient_t *hgc_open(const char *socknam'
432 addr.sun_path, errno);
427 addr.sun_path, errno);
433 }
428 }
434
429
435 hgclient_t *hgc = malloc(sizeof(hgclient_t));
430 hgclient_t *hgc = mallocx(sizeof(hgclient_t));
436 if (!hgc)
437 abortmsg("failed to allocate hgclient object");
438 memset(hgc, 0, sizeof(*hgc));
431 memset(hgc, 0, sizeof(*hgc));
439 hgc->sockfd = fd;
432 hgc->sockfd = fd;
440 initcontext(&hgc->ctx);
433 initcontext(&hgc->ctx);
General Comments 0
You need to be logged in to leave comments. Login now