On 08/05/2014 06:05 AM, Michael S. Tsirkin wrote:
> On Tue, Aug 05, 2014 at 05:55:49AM -0600, Eric Blake wrote:
>> On 08/04/2014 09:33 PM, Ming Lei wrote:
>>> This patch introduces object allocation pool for speeding up
>>> object allocation in fast path.
>>>
>>> Signed-off-by: Ming Lei <ming....@canonical.com>
>>> ---
>>>  include/qemu/obj_pool.h |   64 
>>> +++++++++++++++++++++++++++++++++++++++++++++++
>>>  1 file changed, 64 insertions(+)
>>>  create mode 100644 include/qemu/obj_pool.h
>>>

>>> +
>>> +    char *objs;
>>> +} ObjPool;
>>> +
>>> +static inline void obj_pool_init(ObjPool *op, void *objs_buf, void 
>>> **free_objs,
>>> +                                 unsigned int obj_size, unsigned cnt)
>>> +{
>>> +    int i;
>>> +
>>> +    op->objs = (char *)objs_buf;
>>
>> Why the cast? This is C, not C++.
> 
> It's not needed in C++ either, right?

In C++, going from void* to a typed pointer requires a cast (that's why
in C++ you see casts on malloc results).  In C, void* can implicitly be
converted to any other pointer (modulo const-/volatile-correctness).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to