- use static vars and functions where possible.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 28 Aug 2011 05:06:30 +0000 (05:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 28 Aug 2011 05:06:30 +0000 (05:06 +0000)
- use NULL rather than 0 when used as pointers.

28 files changed:
intern/guardedalloc/intern/mallocn.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/seqeffects.c
source/blender/blenlib/intern/BLI_ghash.c
source/blender/blenlib/intern/callbacks.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/render/render_preview.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_select.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_texture.c
source/blender/python/intern/bpy_intern_string.c
source/blender/python/intern/bpy_props.c
source/blender/render/intern/source/pointdensity.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_keymap.c

index 55340d6..2421c25 100644 (file)
@@ -429,7 +429,7 @@ static int compare_len(const void *p1, const void *p2)
                return -1;
 }
 
-void MEM_printmemlist_stats()
+void MEM_printmemlist_stats(void)
 {
        MemHead *membl;
        MemPrintBlock *pb, *printblock;
index 9c455e8..2961598 100644 (file)
@@ -515,7 +515,7 @@ short *give_totcolp_id(ID *id)
        return NULL;
 }
 
-void data_delete_material_index_id(ID *id, int index)
+static void data_delete_material_index_id(ID *id, int index)
 {
        switch(GS(id->name)) {
        case ID_ME:
@@ -1365,7 +1365,7 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col)
 }
 
 /* copy/paste buffer, if we had a propper py api that would be better */
-Material matcopybuf;
+static Material matcopybuf;
 static short matcopied= 0;
 
 void clear_matcopybuf(void)
index cf95692..8b50ad2 100644 (file)
@@ -2873,7 +2873,7 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq,
 {
        Editing * ed;
        ListBase * seqbasep;
-       struct ImBuf * i = 0;
+       struct ImBuf * i= NULL;
 
        ed = context.scene->ed;
 
@@ -2908,7 +2908,7 @@ static struct ImBuf * do_adjustment(
        struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), 
        struct ImBuf *UNUSED(ibuf3))
 {
-       struct ImBuf * i = 0;
+       struct ImBuf * i = NULL;
        struct ImBuf * out;
        Editing * ed;
 
index bfee350..03e3b7a 100644 (file)
@@ -40,7 +40,7 @@
 #include "BLO_sys_types.h" // for intptr_t support
 /***/
 
-unsigned int hashsizes[]= {
+static unsigned int hashsizes[]= {
        5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 
        16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 
        4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 
index a033e01..d28f794 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "MEM_guardedalloc.h"
 
-static ListBase callback_slots[BLI_CB_EVT_TOT]= {{0}};
+static ListBase callback_slots[BLI_CB_EVT_TOT]= {{NULL}};
 
 void BLI_exec_cb(struct Main *main, struct ID *self, eCbEvent evt)
 {
index 3575a85..ef88bb0 100644 (file)
@@ -1361,7 +1361,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
 static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
 {
        MenuType *mt= (MenuType*)arg_mt;
-       Menu menu = {0};
+       Menu menu = {NULL};
 
        menu.type= mt;
        menu.layout= layout;
index b8cdc18..4b0c1cb 100644 (file)
@@ -3988,7 +3988,7 @@ static void PTCacheUndo_clear(PTCacheEdit *edit)
 {
        PTCacheUndo *undo;
 
-       if(edit==0) return;
+       if(edit==NULL) return;
        
        undo= edit->undo.first;
        while(undo) {
index 007ae96..b937f9a 100644 (file)
@@ -64,6 +64,7 @@
 #include "DNA_brush_types.h"
 #include "DNA_screen_types.h"
 
+#include "BKE_brush.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_global.h"
index 0ac3085..ede1779 100644 (file)
@@ -1702,7 +1702,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
        return OPERATOR_RUNNING_MODAL;
 }
 
-int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
+static int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
 {
        MEM_freeN(op->customdata);
        op->customdata = NULL;
index 3560bfb..74e9e77 100644 (file)
@@ -231,7 +231,7 @@ void outliner_free_tree(ListBase *lb)
 }
 
 /* Find ith item from the treestore */
-TreeElement *outliner_find_tree_element(ListBase *lb, int store_index)
+static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index)
 {
        TreeElement *te= lb->first, *tes;
        while(te) {
index dc84289..9a904b1 100644 (file)
@@ -700,7 +700,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
        }
 }
 
-static Sequence *special_seq_update= 0;
+static Sequence *special_seq_update= NULL;
 
 static void UNUSED_FUNCTION(set_special_seq_update)(int val)
 {
@@ -710,14 +710,14 @@ static void UNUSED_FUNCTION(set_special_seq_update)(int val)
        if(val) {
 // XXX         special_seq_update= find_nearest_seq(&x);
        }
-       else special_seq_update= 0;
+       else special_seq_update= NULL;
 }
 
 void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs)
 {
        struct Main *bmain= CTX_data_main(C);
-       struct ImBuf *ibuf = 0;
-       struct ImBuf *scope = 0;
+       struct ImBuf *ibuf= NULL;
+       struct ImBuf *scope= NULL;
        struct View2D *v2d = &ar->v2d;
        int rectx, recty;
        float viewrectx, viewrecty;
index 0ac2376..86b28f5 100644 (file)
@@ -846,7 +846,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op)
        for(seq= ed->seqbasep->first; seq; seq= seq->next) {
                seq_rectf(seq, &rq);
                
-               if(BLI_isect_rctf(&rq, &rectf, 0)) {
+               if(BLI_isect_rctf(&rq, &rectf, NULL)) {
                        if(selecting)           seq->flag |= SELECT;
                        else                            seq->flag &= ~SEQ_ALLSEL;
                        recurs_sel_seq(seq);
index 910576f..7749883 100644 (file)
@@ -82,7 +82,7 @@ typedef enum GPUDataSource {
 } GPUDataSource;
 
 static const char* GPU_DATATYPE_STR[17] = {"", "float", "vec2", "vec3", "vec4",
-       0, 0, 0, 0, "mat3", 0, 0, 0, 0, 0, 0, "mat4"};
+       NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4"};
 
 struct GPUNode {
        struct GPUNode *next, *prev;
@@ -451,7 +451,7 @@ static int codegen_input_has_texture(GPUInput *input)
        else if(input->ima)
                return 1;
        else
-               return input->tex != 0;
+               return input->tex != NULL;
 }
 
 const char *GPU_builtin_name(GPUBuiltin builtin)
@@ -880,7 +880,7 @@ void GPU_pass_unbind(GPUPass *pass)
                        GPU_texture_unbind(input->tex);
 
                if (input->ima)
-                       input->tex = 0;
+                       input->tex = NULL;
        }
        
        GPU_shader_unbind(shader);
index 9878d83..7af5ef6 100644 (file)
@@ -308,7 +308,7 @@ void GPU_set_anisotropic(float value)
        }
 }
 
-float GPU_get_anisotropic()
+float GPU_get_anisotropic(void)
 {
        return GTS.anisotropic;
 }
index f6352a9..c9f1b09 100644 (file)
@@ -484,7 +484,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels)
        //if (fpixels)
        //      pixels = GPU_texture_convert_pixels(w*h*depth, fpixels);
 
-       glTexImage3D(tex->target, 0, internalformat, tex->w, tex->h, tex->depth, 0, format, type, 0);
+       glTexImage3D(tex->target, 0, internalformat, tex->w, tex->h, tex->depth, 0, format, type, NULL);
 
        GPU_print_error("3D glTexImage3D");
 
index 80299d4..3e5e7bb 100644 (file)
@@ -137,18 +137,18 @@ const char *includefiles[] = {
        ""
 };
 
-int maxdata= 500000, maxnr= 50000;
-int nr_names=0;
-int nr_types=0;
-int nr_structs=0;
-char **names, *namedata;               /* at address names[a] is string a */
-char **types, *typedata;               /* at address types[a] is string a */
-short *typelens;                               /* at typelens[a] is de length of type a */
-short *alphalens;                          /* contains sizes as they are calculated on the DEC Alpha (64 bits) */
-short **structs, *structdata;  /* at sp= structs[a] is the first address of a struct definition
-                                                                  sp[0] is type number
-                                                                  sp[1] is amount of elements
-                                                                  sp[2] sp[3] is typenr,  namenr (etc) */
+static int maxdata= 500000, maxnr= 50000;
+static int nr_names=0;
+static int nr_types=0;
+static int nr_structs=0;
+static char **names, *namedata;                /* at address names[a] is string a */
+static char **types, *typedata;                /* at address types[a] is string a */
+static short *typelens;                                /* at typelens[a] is de length of type a */
+static short *alphalens;                       /* contains sizes as they are calculated on the DEC Alpha (64 bits), infact any 64bit system */
+static short **structs, *structdata;/* at sp= structs[a] is the first address of a struct definition
+                                                                      sp[0] is type number
+                                                                  sp[1] is amount of elements
+                                                                  sp[2] sp[3] is typenr,  namenr (etc) */
 /**
  * Variable to control debug output of makesdna.
  * debugSDNA:
@@ -157,8 +157,8 @@ short **structs, *structdata;       /* at sp= structs[a] is the first address of a str
  *  - 2 = full trace, tell which names and types were found
  *  - 4 = full trace, plus all gritty details
  */
-int debugSDNA = 0;
-int additional_slen_offset;
+static int debugSDNA = 0;
+static int additional_slen_offset;
 
 /* ************************************************************************** */
 /* Functions                                                                  */
@@ -889,7 +889,7 @@ void printStructLenghts(void)
 }
 
 
-int make_structDNA(char *baseDirectory, FILE *file)
+static int make_structDNA(char *baseDirectory, FILE *file)
 {
        int len, i;
        short *sp;
index d47abce..b95bd2b 100644 (file)
@@ -66,7 +66,7 @@ static int file_older(const char *file1, const char *file2)
 
        return (st1.st_mtime < st2.st_mtime);
 }
-const char *makesrna_path= NULL;
+static const char *makesrna_path= NULL;
 
 static int replace_if_different(char *tmpfile, const char *dep_files[])
 {
index 8ac620c..ea03640 100644 (file)
@@ -38,6 +38,7 @@
 #include "RNA_define.h"
 #include "RNA_access.h"
 #include "RNA_enum_types.h"
+#include "rna_internal.h"
 
 #include "BKE_utildefines.h"
 
index 5c5391b..37a629f 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "rna_internal.h"
 
index 7fd6a9d..56492a5 100644 (file)
@@ -732,7 +732,7 @@ static StructRNA* def_node(BlenderRNA *brna, int node_id)
        return srna;
 }
 
-void alloc_node_type_items(EnumPropertyItem *items, int category)
+static void alloc_node_type_items(EnumPropertyItem *items, int category)
 {
        int i;
        int count = 3;
index 463f65f..490d9c3 100644 (file)
@@ -43,7 +43,7 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
-EnumPropertyItem effector_shape_items[] = {
+static EnumPropertyItem effector_shape_items[] = {
        {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
        {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
        {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Surface", ""},
@@ -51,20 +51,23 @@ EnumPropertyItem effector_shape_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem curve_shape_items[] = {
+#ifdef RNA_RUNTIME
+
+/* type spesific return values only used from functions */
+static EnumPropertyItem curve_shape_items[] = {
        {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
        {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
        {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem empty_shape_items[] = {
+static EnumPropertyItem empty_shape_items[] = {
        {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
        {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem vortex_shape_items[] = {
+static EnumPropertyItem vortex_shape_items[] = {
        {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
        {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
        {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Surface falloff (New)", ""},
@@ -72,21 +75,19 @@ EnumPropertyItem vortex_shape_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem curve_vortex_shape_items[] = {
+static EnumPropertyItem curve_vortex_shape_items[] = {
        {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
        {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
        {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve (New)", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem empty_vortex_shape_items[] = {
+static EnumPropertyItem empty_vortex_shape_items[] = {
        {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
        {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-#ifdef RNA_RUNTIME
-
 #include "MEM_guardedalloc.h"
 
 #include "DNA_modifier_types.h"
index 30fce57..ba91fc3 100644 (file)
@@ -33,6 +33,7 @@
 #include "limits.h"
 
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "rna_internal.h"
 
 #include "WM_types.h"
 #include "WM_api.h"
 
-EnumPropertyItem part_from_items[] = {
+static EnumPropertyItem part_from_items[] = {
        {PART_FROM_VERT, "VERT", 0, "Verts", ""},
        {PART_FROM_FACE, "FACE", 0, "Faces", ""},
        {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem part_reactor_from_items[] = {
+static EnumPropertyItem part_reactor_from_items[] = {
        {PART_FROM_VERT, "VERT", 0, "Verts", ""},
        {PART_FROM_FACE, "FACE", 0, "Faces", ""},
        {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem part_dist_items[] = {
+static EnumPropertyItem part_dist_items[] = {
        {PART_DISTR_JIT, "JIT", 0, "Jittered", ""},
        {PART_DISTR_RAND, "RAND", 0, "Random", ""},
        {PART_DISTR_GRID, "GRID", 0, "Grid", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem part_hair_dist_items[] = {
+static EnumPropertyItem part_hair_dist_items[] = {
        {PART_DISTR_JIT, "JIT", 0, "Jittered", ""},
        {PART_DISTR_RAND, "RAND", 0, "Random", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem part_draw_as_items[] = {
+static EnumPropertyItem part_draw_as_items[] = {
        {PART_DRAW_NOT, "NONE", 0, "None", ""},
        {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
        {PART_DRAW_DOT, "DOT", 0, "Point", ""},
@@ -87,14 +88,14 @@ EnumPropertyItem part_draw_as_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem part_hair_draw_as_items[] = {
+static EnumPropertyItem part_hair_draw_as_items[] = {
        {PART_DRAW_NOT, "NONE", 0, "None", ""},
        {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
        {PART_DRAW_PATH, "PATH", 0, "Path", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem part_ren_as_items[] = {
+static EnumPropertyItem part_ren_as_items[] = {
        {PART_DRAW_NOT, "NONE", 0, "None", ""},
        {PART_DRAW_HALO, "HALO", 0, "Halo", ""},
        {PART_DRAW_LINE, "LINE", 0, "Line", ""},
@@ -105,7 +106,7 @@ EnumPropertyItem part_ren_as_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem part_hair_ren_as_items[] = {
+static EnumPropertyItem part_hair_ren_as_items[] = {
        {PART_DRAW_NOT, "NONE", 0, "None", ""},
        {PART_DRAW_PATH, "PATH", 0, "Path", ""},
        {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
index f459563..0ecc41d 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "rna_internal.h"
 
@@ -47,7 +48,7 @@
 
 #include "BKE_node.h"
 
-EnumPropertyItem texture_filter_items[] = {
+static EnumPropertyItem texture_filter_items[] = {
        {TXF_BOX, "BOX", 0, "Box", ""},
        {TXF_EWA, "EWA", 0, "EWA", ""},
        {TXF_FELINE, "FELINE", 0, "FELINE", ""},
index c662900..6fc861b 100644 (file)
 
 #include <Python.h>
 
+#include "bpy_intern_string.h"
+
 PyObject *bpy_intern_str_register;
 PyObject *bpy_intern_str_unregister;
 PyObject *bpy_intern_str_bl_rna;
 PyObject *bpy_intern_str_order;
 PyObject *bpy_intern_str_attr;
 PyObject *bpy_intern_str___slots__;
-PyObject *bpy_intern_str___bases__;
 
 void bpy_intern_string_init(void)
 {
index a0ad1ff..5da142a 100644 (file)
@@ -117,7 +117,7 @@ static PyObject *pymeth_PointerProperty= NULL;
 static PyObject *pymeth_CollectionProperty= NULL;
 static PyObject *pymeth_RemoveProperty= NULL;
 
-PyObject *pyrna_struct_as_instance(PointerRNA *ptr)
+static PyObject *pyrna_struct_as_instance(PointerRNA *ptr)
 {
        PyObject *self= NULL;
        /* first get self */
@@ -177,7 +177,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
 }
 
 /* callbacks */
-void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop)
+static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop)
 {
        PyGILState_STATE gilstate;
        PyObject **py_data= (PyObject **)RNA_property_py_data_get(prop);
index b45528b..980f6b6 100644 (file)
@@ -104,7 +104,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
 {
        DerivedMesh* dm;
        ParticleKey state;
-       ParticleSimulationData sim= {0};
+       ParticleSimulationData sim= {NULL};
        ParticleData *pa=NULL;
        float cfra = BKE_curframe(re->scene);
        int i, childexists;
index cf91e21..850de90 100644 (file)
@@ -116,7 +116,7 @@ static void wm_free_reports(bContext *C)
        BKE_reports_clear(CTX_wm_reports(C));
 }
 
-int wm_start_with_console = 0;
+int wm_start_with_console = 0; /* used in creator.c */
 
 /* only called once, for startup */
 void WM_init(bContext *C, int argc, const char **argv)
index 6887aa4..0e94ad7 100644 (file)
@@ -225,7 +225,7 @@ static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname)
        return NULL;
 }
 
-wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
+static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
 {
        wmKeyConfig *keyconf;