Re: Testing on NULL an unitialized values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2010-04-21 at 12:33 +0200, Oliver Bandel wrote:

> Example:
> 
> 
> ==============================================
> /*****************************************************************************/
> /*  public functions   
> ********************************************************/
> 
> GimpContext *
> gimp_context_new (Gimp        *gimp,
>                    const gchar *name,
>                    GimpContext *template)
> {
>    GimpContext *context;
> 
>    g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
>    g_return_val_if_fail (name != NULL, NULL);
>    g_return_val_if_fail (! template || GIMP_IS_CONTEXT (template), NULL);
> 
>    context = g_object_new (GIMP_TYPE_CONTEXT,
>                            "name", name,
>                            "gimp", gimp,
>                            NULL);
> 
>    if (template)
>      {
>        context->defined_props = template->defined_props;
> 
>        gimp_context_copy_properties (template, context,
>                                      GIMP_CONTEXT_ALL_PROPS_MASK);
>      }
> 
>    return context;
> }
> ==============================================
> 
> The test
>    if( template )
> makes only sense, if you can be sure that uninitialzed values
> will definitely be NULL.

"template" isn't uninitialized here. It is a parameter passed to
gimp_context_new() and it may either be NULL or a pointer to a valid
GimpContext object. This is even checked right at the beginning of the
function.


Sven


_______________________________________________
Gimp-developer mailing list
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux