Skip to content
  • Sebastian Wick's avatar
    3f71e403
    gvariant: Introduce G_VARIANT_BUILDER_INIT_UNSET · 3f71e403
    Sebastian Wick authored
    For g_auto(GVariantBuilder) one needs to initialize it before the
    function returns, so it's best to do it when the variable is declared.
    G_VARIANT_BUILDER_INIT exists but requires specifying a GVariantType in
    the declaration which moves the type away from the usage of the builder
    which often results in less readable code. G_VARIANT_BUILDER_INIT also
    mentions that it's possible to explicitly zero the variable but this is
    hard to find and writing `g_auto(GVariantBuilder) builder = {0,};` is
    kind of ugly.
    
    This introduces G_VARIANT_BUILDER_INIT_UNSET which zero initializes the
    variable being declared. This gives us documentation and hides the
    explicitly zeroing detail:
    
      auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT_UNSET ();
    3f71e403
    gvariant: Introduce G_VARIANT_BUILDER_INIT_UNSET
    Sebastian Wick authored
    For g_auto(GVariantBuilder) one needs to initialize it before the
    function returns, so it's best to do it when the variable is declared.
    G_VARIANT_BUILDER_INIT exists but requires specifying a GVariantType in
    the declaration which moves the type away from the usage of the builder
    which often results in less readable code. G_VARIANT_BUILDER_INIT also
    mentions that it's possible to explicitly zero the variable but this is
    hard to find and writing `g_auto(GVariantBuilder) builder = {0,};` is
    kind of ugly.
    
    This introduces G_VARIANT_BUILDER_INIT_UNSET which zero initializes the
    variable being declared. This gives us documentation and hides the
    explicitly zeroing detail:
    
      auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT_UNSET ();
Loading