libdrm: reduce number of reallocations in drmModeAtomicAddProperty

When calling drmModeAtomicAddProperty allocation of memory happens as
needed in increments of 16 elements. This can be very slow if there are
multiple properties to be updated in an Atomic Commit call.

Increase this to as many as can fit in a memory PAGE to avoid having to
reallocate memory too often.

Bug: 111047515
Change-Id: I043db1e7608b0a606adf1a6e468c90734372f363
diff --git a/xf86drmMode.c b/xf86drmMode.c
index e1c9974..2876b42 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1507,7 +1507,7 @@
 			return NULL;
 		}
 		memcpy(new->items, old->items,
-		       old->size_items * sizeof(*new->items));
+		       old->cursor * sizeof(*new->items));
 	} else {
 		new->items = NULL;
 	}
@@ -1566,12 +1566,13 @@
 		return -EINVAL;
 
 	if (req->cursor >= req->size_items) {
+		const uint32_t item_size_inc = getpagesize() / sizeof(*req->items);
 		drmModeAtomicReqItemPtr new;
 
-		req->size_items += 16;
+		req->size_items += item_size_inc;
 		new = realloc(req->items, req->size_items * sizeof(*req->items));
 		if (!new) {
-			req->size_items -= 16;
+			req->size_items -= item_size_inc;
 			return -ENOMEM;
 		}
 		req->items = new;