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.