summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index aad6430c417..80c93be70c9 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -617,13 +617,26 @@ static void virgl_drm_add_res(struct virgl_drm_winsys *qdws,
{
unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1);
- if (cbuf->cres > cbuf->nres) {
- cbuf->nres += 256;
- cbuf->res_bo = realloc(cbuf->res_bo, cbuf->nres * sizeof(struct virgl_hw_buf*));
- if (!cbuf->res_bo) {
- fprintf(stderr,"failure to add relocation %d, %d\n", cbuf->cres, cbuf->nres);
+ if (cbuf->cres >= cbuf->nres) {
+ unsigned new_nres = cbuf->nres + 256;
+ void *new_ptr = REALLOC(cbuf->res_bo,
+ cbuf->nres * sizeof(struct virgl_hw_buf*),
+ new_nres * sizeof(struct virgl_hw_buf*));
+ if (!new_ptr) {
+ fprintf(stderr,"failure to add relocation %d, %d\n", cbuf->cres, new_nres);
return;
}
+ cbuf->res_bo = new_ptr;
+
+ new_ptr = REALLOC(cbuf->res_hlist,
+ cbuf->nres * sizeof(uint32_t),
+ new_nres * sizeof(uint32_t));
+ if (!new_ptr) {
+ fprintf(stderr,"failure to add hlist relocation %d, %d\n", cbuf->cres, cbuf->nres);
+ return;
+ }
+ cbuf->res_hlist = new_ptr;
+ cbuf->nres = new_nres;
}
cbuf->res_bo[cbuf->cres] = NULL;