Denis Oliver Kropp wrote:
> object.c: In function 'fusion_object_set_property':
> object.c:507: warning: unused variable 'sharedkey'
Not to offend you, it must have been very late when you wrote this :)
Why is sharedkey unused?
BTW, there's an SHSTRDUP() to avoid doing it by hand.
DirectResult
fusion_object_set_property( FusionObject *object ,
const char *key, void *value, void **old_value)
{
DirectResult ret;
int len;
const char *sharedkey;
D_MAGIC_ASSERT( object, FusionObject );
if(!object->properties){
ret =fusion_hash_create(object->shared->main_pool,HASH_STRING,HASH_PTR,
FUSION_HASH_MIN_SIZE,&object->properties);
if(ret)
return ret;
}
len=strlen(key);
if(len) {
const char *nkey = SHMALLOC(object->shared->main_pool,len+1);
if( !nkey )
return DFB_NOSHAREDMEMORY;
strcpy((char *)nkey,key);
key = nkey;
}
return fusion_hash_replace(object->properties,key,value,NULL,old_value);
}
I'd put it like that:
DirectResult
fusion_object_set_property( FusionObject *object,
const char *key,
void *value,
void **old_value )
{
DirectResult ret;
char *sharedkey;
D_MAGIC_ASSERT( object, FusionObject );
D_ASSERT( object->shared != NULL );
D_ASSERT( key != NULL );
D_ASSERT( value != NULL );
/* Create property hash on demand. */
if (!object->properties) {
ret = fusion_hash_create( object->shared->main_pool,
HASH_STRING, HASH_PTR,
FUSION_HASH_MIN_SIZE,
&object->properties );
if (ret)
return ret;
}
/* Create a shared copy of the key. */
sharedkey = SHSTRDUP( object->shared->main_pool, key );
if (!sharedkey)
return D_OOSHM();
/* Put it into the hash. */
return fusion_hash_replace( object->properties, sharedkey,
value, NULL, old_value );
}
Consistent indent and spacing, assertions where possible,
some empty lines to separate code blocks... :-)
Maybe I'm a bit too perfectionist...
--
Best regards,
Denis Oliver Kropp
.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/ |
"------------------------------------------"
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev