mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-10-20 22:38:09 +00:00
[common] use variable-relative sizeof where possible
This commit is contained in:

committed by
Geoffrey McRae

parent
982b4e6625
commit
1c5620ba25
@@ -164,7 +164,7 @@ static int dl_iterate_phdr_callback(struct dl_phdr_info * info, size_t size, voi
|
||||
ttl += hdr.p_memsz;
|
||||
}
|
||||
|
||||
crash.ranges = realloc(crash.ranges, sizeof(struct range) * (crash.rangeCount + 1));
|
||||
crash.ranges = realloc(crash.ranges, sizeof(*crash.ranges) * (crash.rangeCount + 1));
|
||||
crash.ranges[crash.rangeCount].start = info->dlpi_addr;
|
||||
crash.ranges[crash.rangeCount].end = info->dlpi_addr + ttl;
|
||||
++crash.rangeCount;
|
||||
|
@@ -39,7 +39,7 @@ struct LGEvent
|
||||
|
||||
LGEvent * lgCreateEvent(bool autoReset, unsigned int msSpinTime)
|
||||
{
|
||||
LGEvent * handle = (LGEvent *)calloc(sizeof(LGEvent), 1);
|
||||
LGEvent * handle = (LGEvent *)calloc(sizeof(*handle), 1);
|
||||
if (!handle)
|
||||
{
|
||||
DEBUG_ERROR("Failed to allocate memory");
|
||||
|
@@ -171,8 +171,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct IVSHMEMInfo * info =
|
||||
(struct IVSHMEMInfo *)malloc(sizeof(struct IVSHMEMInfo));
|
||||
struct IVSHMEMInfo * info = (struct IVSHMEMInfo *)malloc(sizeof(*info));
|
||||
info->size = devSize;
|
||||
info->devFd = devFd;
|
||||
info->hasDMA = hasDMA;
|
||||
|
@@ -43,7 +43,7 @@ static void * threadWrapper(void * opaque)
|
||||
|
||||
bool lgCreateThread(const char * name, LGThreadFunction function, void * opaque, LGThread ** handle)
|
||||
{
|
||||
*handle = (LGThread*)malloc(sizeof(LGThread));
|
||||
*handle = (LGThread*)malloc(sizeof(**handle));
|
||||
(*handle)->name = name;
|
||||
(*handle)->function = function;
|
||||
(*handle)->opaque = opaque;
|
||||
|
@@ -49,7 +49,7 @@ static void TimerProc(union sigval arg)
|
||||
bool lgCreateTimer(const unsigned int intervalMS, LGTimerFn fn,
|
||||
void * udata, LGTimer ** result)
|
||||
{
|
||||
LGTimer * ret = malloc(sizeof(LGTimer));
|
||||
LGTimer * ret = malloc(sizeof(*ret));
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
|
Reference in New Issue
Block a user