-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2015-04-08 um 09:10 schrieb Alistair Leslie-Hughes:
+{
- if(This->comp_count == This->comp_array_size)
- {
struct component **temp;
temp = heap_realloc(This->components, sizeof(struct component *) * (This->comp_array_size*2) );
Style hint: You can use sizeof(*temp) here, that way the alloc code doesn't need to be changed when you change the type of temp. This is even more helpful when the declaration of the pointer is in a different file, like in the heap_alloc call that allocates client->components.
- if(This->components)
- {
This->components[This->comp_count] = item;
This->comp_count++;
return TRUE;
- }
Can this ever be NULL for a legitimate reason? Note that the heap_realloc call already assumes This->components is not NULL.
@@ -540,8 +596,8 @@ HRESULT DPNET_CreateDirectPlay8Address(IClassFactory *iface, IUnknown *pUnkOuter
client->IDirectPlay8Address_iface.lpVtbl = &DirectPlay8Address_Vtbl; client->ref = 1;
- list_init(&client->components);
- client->comp_array_size = 4;
- client->components = heap_alloc( sizeof(struct component *) * client->comp_array_size );
Please add error checking here. (The NULL check in add_component doesn't help if this fails. You'll just get a half-working address object where AddComponent always fails)