在 2018/9/12 下午3:35, Yi Min Zhao 写道:
>> +static void *
>> +virZPCIAddrCopy(const void *name)
>> +{
>> + unsigned int *copy;
>> +
>> + if (VIR_ALLOC(copy) < 0)
>> + return NULL;
>> +
>> + *copy = *((unsigned int *)name);
>> + return (void *)copy;
>> +}
>> +
>> +
>> +static void
>> +virZPCIAddrKeyFree(void *name)
>> +{
>> + VIR_FREE(name);
>> +}
> This makes sense and seems to work just fine; however, you are
> allocating and releasing a bunch of small integers, which seems
> a bit wasteful.
>
> vircgroup is AFAICT avoiding all that extra memory management by
> stuffing the values straight into the pointers themselves, which
> you should also be able to do since the biggest legal ID is a
> 32-bit integer.
>
> That said, I haven't been able to get that to actually work, at
> least with a quick attempt :( Would you mind exploring that route
> and figuring out whether it's feasible at all?
I'm testing this. Actually I wanted to do so like vircgroup. I
remembered there's
error due to the previous code logic. I will reply to you later.
I remebered the
reason and test again. FID might be 0. It is treated as
an error
if we save 0 in void* pointer.
--
Yi Min