diff options
author | nicm <nicm> | 2014-10-08 17:35:58 +0000 |
---|---|---|
committer | nicm <nicm> | 2014-10-08 17:35:58 +0000 |
commit | a27ba6e38006c12c48de88600b8cff9f6aabfed7 (patch) | |
tree | fc8ecf1c1b965f70b95d0a3e472cd0b1a2e1d2c9 /grid.c | |
parent | 77efcf8bdd14cd19dc445cf6e44bba7af414939c (diff) | |
download | rtmux-a27ba6e38006c12c48de88600b8cff9f6aabfed7.tar.gz rtmux-a27ba6e38006c12c48de88600b8cff9f6aabfed7.tar.bz2 rtmux-a27ba6e38006c12c48de88600b8cff9f6aabfed7.zip |
Add xreallocarray and remove nmemb argument from xrealloc.
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -172,7 +172,8 @@ grid_scroll_history(struct grid *gd) u_int yy; yy = gd->hsize + gd->sy; - gd->linedata = xrealloc(gd->linedata, yy + 1, sizeof *gd->linedata); + gd->linedata = xreallocarray(gd->linedata, yy + 1, + sizeof *gd->linedata); memset(&gd->linedata[yy], 0, sizeof gd->linedata[yy]); gd->hsize++; @@ -187,7 +188,8 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower) /* Create a space for a new line. */ yy = gd->hsize + gd->sy; - gd->linedata = xrealloc(gd->linedata, yy + 1, sizeof *gd->linedata); + gd->linedata = xreallocarray(gd->linedata, yy + 1, + sizeof *gd->linedata); /* Move the entire screen down to free a space for this line. */ gl_history = &gd->linedata[gd->hsize]; @@ -221,7 +223,7 @@ grid_expand_line(struct grid *gd, u_int py, u_int sx) if (sx <= gl->cellsize) return; - gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata); + gl->celldata = xreallocarray(gl->celldata, sx, sizeof *gl->celldata); for (xx = gl->cellsize; xx < sx; xx++) grid_put_cell(gd, xx, py, &grid_default_cell); gl->cellsize = sx; @@ -610,7 +612,7 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx, } while (len < off + size + codelen + 1) { - buf = xrealloc(buf, 2, len); + buf = xreallocarray(buf, 2, len); len *= 2; } @@ -685,7 +687,7 @@ grid_reflow_join(struct grid *dst, u_int *py, struct grid_line *src_gl, nx = ox + to_copy; /* Resize the destination line. */ - dst_gl->celldata = xrealloc(dst_gl->celldata, nx, + dst_gl->celldata = xreallocarray(dst_gl->celldata, nx, sizeof *dst_gl->celldata); dst_gl->cellsize = nx; @@ -724,7 +726,7 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl, to_copy = src_gl->cellsize; /* Expand destination line. */ - dst_gl->celldata = xrealloc(NULL, to_copy, + dst_gl->celldata = xreallocarray(NULL, to_copy, sizeof *dst_gl->celldata); dst_gl->cellsize = to_copy; dst_gl->flags |= GRID_LINE_WRAPPED; |