[host] use variable-relative sizeof where possible

This commit is contained in:
Tudor Brindus 2021-08-15 12:18:01 -04:00 committed by Geoffrey McRae
parent c3f7327187
commit 982b4e6625
4 changed files with 10 additions and 10 deletions

View File

@ -64,7 +64,7 @@ static const char * xcb_getName(void)
static bool xcb_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn) static bool xcb_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn)
{ {
DEBUG_ASSERT(!this); DEBUG_ASSERT(!this);
this = (struct xcb *)calloc(sizeof(struct xcb), 1); this = (struct xcb *)calloc(sizeof(*this), 1);
this->shmID = -1; this->shmID = -1;
this->data = (void *)-1; this->data = (void *)-1;
this->frameEvent = lgCreateEvent(true, 20); this->frameEvent = lgCreateEvent(true, 20);

View File

@ -170,7 +170,7 @@ static void dxgi_initOptions(void)
static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn) static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn)
{ {
DEBUG_ASSERT(!this); DEBUG_ASSERT(!this);
this = calloc(sizeof(struct iface), 1); this = calloc(sizeof(*this), 1);
if (!this) if (!this)
{ {
DEBUG_ERROR("failed to allocate iface struct"); DEBUG_ERROR("failed to allocate iface struct");
@ -190,7 +190,7 @@ static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostP
this->maxTextures = 1; this->maxTextures = 1;
this->useAcquireLock = option_get_bool("dxgi", "useAcquireLock"); this->useAcquireLock = option_get_bool("dxgi", "useAcquireLock");
this->texture = calloc(sizeof(struct Texture), this->maxTextures); this->texture = calloc(sizeof(*this->texture), this->maxTextures);
this->getPointerBufferFn = getPointerBufferFn; this->getPointerBufferFn = getPointerBufferFn;
this->postPointerBufferFn = postPointerBufferFn; this->postPointerBufferFn = postPointerBufferFn;
this->avgMapTime = runningavg_new(10); this->avgMapTime = runningavg_new(10);
@ -499,7 +499,7 @@ static bool dxgi_init(void)
output5, output5,
(IUnknown *)this->device, (IUnknown *)this->device,
0, 0,
sizeof(supportedFormats) / sizeof(DXGI_FORMAT), ARRAY_LENGTH(supportedFormats),
supportedFormats, supportedFormats,
&this->dup); &this->dup);
@ -871,7 +871,7 @@ static CaptureResult dxgi_capture(void)
else else
{ {
memcpy(tex->texDamageRects + tex->texDamageCount, tex->damageRects, memcpy(tex->texDamageRects + tex->texDamageCount, tex->damageRects,
tex->damageRectsCount * sizeof(FrameDamageRect)); tex->damageRectsCount * sizeof(*tex->damageRects));
tex->texDamageCount += tex->damageRectsCount; tex->texDamageCount += tex->damageRectsCount;
tex->texDamageCount = rectsMergeOverlapping(tex->texDamageRects, tex->texDamageCount); tex->texDamageCount = rectsMergeOverlapping(tex->texDamageRects, tex->texDamageCount);
} }
@ -920,7 +920,7 @@ static CaptureResult dxgi_capture(void)
t->texDamageCount + tex->damageRectsCount <= KVMFR_MAX_DAMAGE_RECTS) t->texDamageCount + tex->damageRectsCount <= KVMFR_MAX_DAMAGE_RECTS)
{ {
memcpy(t->texDamageRects + t->texDamageCount, tex->damageRects, memcpy(t->texDamageRects + t->texDamageCount, tex->damageRects,
tex->damageRectsCount * sizeof(FrameDamageRect)); tex->damageRectsCount * sizeof(*tex->damageRects));
t->texDamageCount += tex->damageRectsCount; t->texDamageCount += tex->damageRectsCount;
} }
else else
@ -1093,7 +1093,7 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame,
else else
{ {
memcpy(damage->rects + damage->count, tex->damageRects, memcpy(damage->rects + damage->count, tex->damageRects,
tex->damageRectsCount * sizeof(FrameDamageRect)); tex->damageRectsCount * sizeof(*tex->damageRects));
damage->count += tex->damageRectsCount; damage->count += tex->damageRectsCount;
rectsBufferToFramebuffer(damage->rects, damage->count, frame, this->pitch, rectsBufferToFramebuffer(damage->rects, damage->count, frame, this->pitch,
height, tex->map.pData, this->pitch); height, tex->map.pData, this->pitch);
@ -1108,7 +1108,7 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame,
damage->count + tex->damageRectsCount <= KVMFR_MAX_DAMAGE_RECTS) damage->count + tex->damageRectsCount <= KVMFR_MAX_DAMAGE_RECTS)
{ {
memcpy(damage->rects + damage->count, tex->damageRects, memcpy(damage->rects + damage->count, tex->damageRects,
tex->damageRectsCount * sizeof(FrameDamageRect)); tex->damageRectsCount * sizeof(*tex->damageRects));
damage->count += tex->damageRectsCount; damage->count += tex->damageRectsCount;
} }
else else

View File

@ -153,7 +153,7 @@ static bool nvfbc_create(
if (!NvFBCInit()) if (!NvFBCInit())
return false; return false;
this = (struct iface *)calloc(sizeof(struct iface), 1); this = (struct iface *)calloc(sizeof(*this), 1);
this->seperateCursor = option_get_bool("nvfbc", "decoupleCursor"); this->seperateCursor = option_get_bool("nvfbc", "decoupleCursor");
this->getPointerBufferFn = getPointerBufferFn; this->getPointerBufferFn = getPointerBufferFn;

View File

@ -133,7 +133,7 @@ bool NvFBCToSysCreate(
return false; return false;
} }
*handle = (NvFBCHandle)calloc(sizeof(struct stNvFBCHandle), 1); *handle = (NvFBCHandle)calloc(sizeof(**handle), 1);
(*handle)->nvfbc = static_cast<NvFBCToSys *>(params.pNvFBC); (*handle)->nvfbc = static_cast<NvFBCToSys *>(params.pNvFBC);
if (maxWidth) if (maxWidth)