- use static vars and functions where possible.

- use NULL rather than 0 when used as pointers.
This commit is contained in:
Campbell Barton
2011-08-28 05:06:30 +00:00
parent c73d5b939d
commit fa2ba5fbf5
28 changed files with 68 additions and 61 deletions

View 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;

View 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)

View 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;

View 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,

View 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)
{

View 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;

View 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) {

View 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"

View 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;

View 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) {

View 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;

View 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);

View 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);

View File

@@ -308,7 +308,7 @@ void GPU_set_anisotropic(float value)
}
}
float GPU_get_anisotropic()
float GPU_get_anisotropic(void)
{
return GTS.anisotropic;
}

View 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");

View 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;

View 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[])
{

View 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"

View File

@@ -32,6 +32,7 @@
#include <stdlib.h>
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "rna_internal.h"

View 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;

View 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"

View File

@@ -33,6 +33,7 @@
#include "limits.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "rna_internal.h"
@@ -50,34 +51,34 @@
#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", ""},

View 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", ""},

View File

@@ -28,13 +28,14 @@
#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)
{

View 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);

View 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;

View 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)

View 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;