[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: [PATCH 1/2] d3d10: Add a function to initialize the null
From:       Henri Verbeet <hverbeet () gmail ! com>
Date:       2009-12-31 16:52:06
Message-ID: d658b69e0912310852l325e6b16i9cbce872ff8bff6a () mail ! gmail ! com
[Download RAW message or body]

2009/12/31 Rico Schüller <kgbricola@web.de>:
> +static struct d3d10_effect_variable null_local_buffer = {0};
> +static struct d3d10_effect_variable null_variable = {0};
> +static struct d3d10_effect_variable null_scalar_variable = {0};
> +static struct d3d10_effect_variable null_vector_variable = {0};
> +static struct d3d10_effect_variable null_matrix_variable = {0};
> +static struct d3d10_effect_variable null_string_variable = {0};
> +static struct d3d10_effect_variable null_shader_resource_variable = {0};
> +static struct d3d10_effect_variable null_render_target_view_variable = {0};
> +static struct d3d10_effect_variable null_depth_stencil_view_variable = {0};
> +static struct d3d10_effect_variable null_shader_variable = {0};
> +static struct d3d10_effect_variable null_blend_variable = {0};
> +static struct d3d10_effect_variable null_depth_stencil_variable = {0};
> +static struct d3d10_effect_variable null_rasterizer_variable = {0};
> +static struct d3d10_effect_variable null_sampler_variable = {0};
This doesn't hurt (much), but since a lot of people seem to be unaware
of this I think it's worth mentioning again. Global variables as well
as static (local) variables are initialized to 0 / NULL by default.

The way this works in the language spec is that objects with static
storage duration (i.e. the entire lifetime of the program/module) are
initialized to 0 / NULL unless explicitly initialized. In practice
that means global and static variables (but note that static on a
global variable or function has a different meaning from static on a
local variable).

> +static void d3d10_null_effect_variable_init(struct d3d10_effect_variable *v, \
> struct ID3D10EffectVariableVtbl *vtbl) +{
> +    v->vtbl = vtbl;
> +    v->buffer = &null_local_buffer;
> +    v->effect = NULL;
> +    v->name = NULL;
> +    v->semantic = NULL;
> +    v->buffer_offset = 0;
> +    v->annotation_count = 0;
> +    v->flag = 0;
> +    v->data_size = 0;
> +    v->type = &null_type;
> +    v->elements = NULL;
> +    v->members = NULL;
> +    v->annotations = NULL;
> +}
Most of these are redundant, since the variable will be already
initialized with zeroes.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic