From a79e10157dc7a1c8a102bf88f236d325ecdd8d80 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Mar 2013 05:34:10 +0000 Subject: code cleanup: use NULL rather then 0 for pointers, and make vars static where possible. also found unintentionally defined enum/struct variables that where only meant to be defining the type. --- intern/raskter/raskter.c | 2 +- source/blender/blenkernel/intern/bpath.c | 4 +- source/blender/blenkernel/intern/image.c | 6 +-- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/writeavi.c | 2 +- source/blender/blenlib/intern/fileops.c | 4 +- source/blender/blenlib/intern/voronoi.c | 2 +- source/blender/blenloader/intern/writefile.c | 4 +- source/blender/editors/object/object_bake.c | 4 +- source/blender/editors/object/object_select.c | 2 +- source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- source/blender/editors/space_node/node_group.c | 2 +- .../blender/editors/space_text/text_format_lua.c | 2 +- .../blender/editors/space_text/text_format_osl.c | 2 +- source/blender/editors/space_text/text_format_py.c | 2 +- source/blender/imbuf/intern/cineon/cineon_dpx.c | 22 +++++----- source/blender/imbuf/intern/cineon/cineonlib.c | 44 +++++++++---------- source/blender/imbuf/intern/cineon/dpxlib.c | 50 +++++++++++----------- source/blender/imbuf/intern/cineon/logImageCore.c | 40 ++++++++--------- source/blender/imbuf/intern/scaling.c | 2 +- source/blender/modifiers/intern/MOD_boolean_util.c | 10 ++--- .../blender/python/bmesh/bmesh_py_types_meshdata.c | 2 +- .../blender/python/intern/bpy_app_translations.c | 6 +-- source/blender/windowmanager/intern/wm_init_exit.c | 2 +- source/creator/creator.c | 4 +- 25 files changed, 112 insertions(+), 112 deletions(-) diff --git a/intern/raskter/raskter.c b/intern/raskter/raskter.c index 21153082324..4f65f877316 100644 --- a/intern/raskter/raskter.c +++ b/intern/raskter/raskter.c @@ -420,7 +420,7 @@ int PLX_raskterize(float(*base_verts)[2], int num_base_verts, { int i; /* i: Loop counter. */ struct PolyVert *ply; /* ply: Pointer to a list of integer buffer-space vertex coordinates. */ - struct r_FillContext ctx = {0}; + struct r_FillContext ctx = {NULL}; const float buf_x_f = (float)(buf_x); const float buf_y_f = (float)(buf_y); /* diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index b0021050e8f..da8b97976f3 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -671,14 +671,14 @@ int BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pat struct PathStore { struct PathStore *next, *prev; -} PathStore; +}; static int bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src) { /* store the path and string in a single alloc */ ListBase *ls = userdata; size_t path_size = strlen(path_src) + 1; - struct PathStore *path_store = MEM_mallocN(sizeof(PathStore) + path_size, __func__); + struct PathStore *path_store = MEM_mallocN(sizeof(struct PathStore) + path_size, __func__); char *filepath = (char *)(path_store + 1); memcpy(filepath, path_src, path_size); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4e79c086d4d..26651d76f68 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1819,7 +1819,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec } /* cleanup the buffer. */ - BLF_buffer(mono, NULL, NULL, 0, 0, 0, FALSE); + BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL); #undef BUFF_MARGIN_X #undef BUFF_MARGIN_Y @@ -3379,7 +3379,7 @@ void BKE_image_get_aspect(Image *image, float *aspx, float *aspy) unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame) { - ImageUser iuser = {0}; + ImageUser iuser = {NULL}; void *lock; ImBuf *ibuf; unsigned char *pixels = NULL; @@ -3406,7 +3406,7 @@ unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame) float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame) { - ImageUser iuser = {0}; + ImageUser iuser = {NULL}; void *lock; ImBuf *ibuf; float *pixels = NULL; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 559a1cb7136..4151120b12f 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2445,7 +2445,7 @@ typedef struct bNodeClipboard { int type; } bNodeClipboard; -bNodeClipboard node_clipboard = {{0}}; +static bNodeClipboard node_clipboard = {{NULL}}; void BKE_node_clipboard_init(struct bNodeTree *ntree) { diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index d4428be3faf..ff6212f6b09 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -73,7 +73,7 @@ static void filepath_avi(char *string, RenderData *rd); bMovieHandle *BKE_movie_handle_get(const char imtype) { - static bMovieHandle mh = {0}; + static bMovieHandle mh = {NULL}; /* set the default handle, as builtin */ #ifdef WITH_AVI diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 29280c36222..8b3cfd07ee9 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -423,7 +423,7 @@ enum { /* error occured in callback and recursive walking should stop immediately */ RecursiveOp_Callback_Error = 2 -} recuresiveOp_Callback_Result; +}; typedef int (*RecursiveOp_Callback)(const char *from, const char *to); @@ -498,7 +498,7 @@ static int recursive_operation(const char *startfrom, const char *startto, break; } - n = scandir(startfrom, &dirlist, 0, alphasort); + n = scandir(startfrom, &dirlist, NULL, alphasort); if (n < 0) { /* error opening directory for listing */ perror("scandir"); diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 601b07c9a5d..7a545090090 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -44,7 +44,7 @@ enum { voronoiEventType_Site = 0, voronoiEventType_Circle = 1 -} voronoiEventType; +}; typedef struct VoronoiEvent { struct VoronoiEvent *next, *prev; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index bded9358d56..64aff1ab22f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1803,7 +1803,7 @@ static void write_meshs(WriteData *wd, ListBase *idbase) if (!save_for_old_blender) { #ifdef USE_BMESH_SAVE_WITHOUT_MFACE - Mesh backup_mesh = {{0}}; + Mesh backup_mesh = {{NULL}}; /* cache only - don't write */ backup_mesh.mface = mesh->mface; mesh->mface = NULL; @@ -1846,7 +1846,7 @@ static void write_meshs(WriteData *wd, ListBase *idbase) #ifdef USE_BMESH_SAVE_AS_COMPAT - Mesh backup_mesh = {{0}}; + Mesh backup_mesh = {{NULL}}; /* backup */ backup_mesh.mpoly = mesh->mpoly; diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 8c8e4878166..00af771e45d 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -323,7 +323,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - MultiresBakeRender bkr = {0}; + MultiresBakeRender bkr = {NULL}; ob = base->object; @@ -419,7 +419,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa } for (data = bkj->data.first; data; data = data->next) { - MultiresBakeRender bkr = {0}; + MultiresBakeRender bkr = {NULL}; /* copy data stored in job descriptor */ bkr.bake_filter = bkj->bake_filter; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 58e51fa0603..b7303b2af51 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -439,7 +439,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else if (nr == OBJECT_SELECT_LINKED_OBDATA) { - if (ob->data == 0) + if (ob->data == NULL) return OPERATOR_CANCELLED; changed = object_select_all_by_obdata(C, ob->data); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 9ba50e95d81..197231124fc 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -293,7 +293,7 @@ static void do_shared_vertexcol(Mesh *me, int do_tessface) /* if no mloopcol: do not do */ /* if mtexpoly: only the involved faces, otherwise all */ - if (me->mloopcol == 0 || me->totvert == 0 || me->totpoly == 0) return; + if (me->mloopcol == NULL || me->totvert == 0 || me->totpoly == 0) return; scol = MEM_callocN(sizeof(float) * me->totvert * 5, "scol"); diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index b1e43a2ef0c..30ba4108143 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -552,7 +552,7 @@ typedef enum eNodeGroupSeparateType { } eNodeGroupSeparateType; /* Operator Property */ -EnumPropertyItem node_group_separate_types[] = { +static EnumPropertyItem node_group_separate_types[] = { {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, {NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c index f74d1cf8e8b..9972c570db7 100644 --- a/source/blender/editors/space_text/text_format_lua.c +++ b/source/blender/editors/space_text/text_format_lua.c @@ -307,7 +307,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const int do_n void ED_text_format_register_lua(void) { - static TextFormatType tft = {0}; + static TextFormatType tft = {NULL}; static const char *ext[] = {"lua", NULL}; tft.format_identifier = txtfmt_lua_format_identifier; diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c index c95929a720f..a4322fb310e 100644 --- a/source/blender/editors/space_text/text_format_osl.c +++ b/source/blender/editors/space_text/text_format_osl.c @@ -325,7 +325,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const int do_n void ED_text_format_register_osl(void) { - static TextFormatType tft = {0}; + static TextFormatType tft = {NULL}; static const char *ext[] = {"osl", NULL}; tft.format_identifier = txtfmt_osl_format_identifier; diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c index 9562d57041f..a401e5dcdac 100644 --- a/source/blender/editors/space_text/text_format_py.c +++ b/source/blender/editors/space_text/text_format_py.c @@ -314,7 +314,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const int do_ne void ED_text_format_register_py(void) { - static TextFormatType tft = {0}; + static TextFormatType tft = {NULL}; static const char *ext[] = {"py", NULL}; tft.format_identifier = txtfmt_py_format_identifier; diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 48bda418d82..255af7dc039 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -63,24 +63,24 @@ static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int us image = logImageOpenFromMemory(mem, size); - if (image == 0) { + if (image == NULL) { printf("DPX/Cineon: error opening image.\n"); - return 0; + return NULL; } logImageGetSize(image, &width, &height, &depth); ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags); - if (ibuf == 0) { + if (ibuf == NULL) { logImageClose(image); - return 0; + return NULL; } if (!(flags & IB_test)) { if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) { logImageClose(image); IMB_freeImBuf(ibuf); - return 0; + return NULL; } IMB_flipy(ibuf); } @@ -127,12 +127,12 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon logImage = logImageCreate(filename, use_cineon, ibuf->x, ibuf->y, bitspersample, (depth == 4), (ibuf->ftype & CINEON_LOG), -1, -1, -1, "Blender"); - if (logImage == 0) { + if (logImage == NULL) { printf("DPX/Cineon: error creating file.\n"); return 0; } - if (ibuf->rect_float != 0 && bitspersample != 8) { + if (ibuf->rect_float != NULL && bitspersample != 8) { /* don't use the float buffer to save 8 bpp picture to prevent color banding * (there's no dithering algorithm behing the logImageSetDataRGBA function) */ @@ -150,11 +150,11 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon MEM_freeN(fbuf); } else { - if (ibuf->rect == 0) + if (ibuf->rect == NULL) IMB_rect_from_float(ibuf); fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon"); - if (fbuf == 0) { + if (fbuf == NULL) { printf("DPX/Cineon: error allocating memory.\n"); logImageClose(logImage); return 0; @@ -191,7 +191,7 @@ ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspa { if (imb_is_cineon(mem)) return imb_load_dpx_cineon(mem, size, 1, flags, colorspace); - return 0; + return NULL; } int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags) @@ -208,5 +208,5 @@ ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[ { if (imb_is_dpx(mem)) return imb_load_dpx_cineon(mem, size, 0, flags, colorspace); - return 0; + return NULL; } diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index 4b9ca1dd539..1481b2aaa66 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -75,7 +75,7 @@ static void fillCineonMainHeader(LogImageFile *cineon, CineonMainHeader *header, strcpy(header->fileHeader.version, "v4.5"); strncpy(header->fileHeader.file_name, filename, 99); header->fileHeader.file_name[99] = 0; - fileClock = time(0); + fileClock = time(NULL); fileTime = localtime(&fileClock); strftime(header->fileHeader.creation_date, 12, "%Y:%m:%d", fileTime); strftime(header->fileHeader.creation_time, 12, "%H:%M:%S%Z", fileTime); @@ -142,28 +142,28 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t int i; unsigned int dataOffset; - if (cineon == 0) { + if (cineon == NULL) { if (verbose) printf("Cineon: Failed to malloc cineon file structure.\n"); - return 0; + return NULL; } /* zero the header */ memset(&header, 0, sizeof(CineonMainHeader)); /* for close routine */ - cineon->file = 0; + cineon->file = NULL; if (fromMemory == 0) { /* byteStuff is then the filename */ cineon->file = BLI_fopen(filename, "rb"); - if (cineon->file == 0) { + if (cineon->file == NULL) { if (verbose) printf("Cineon: Failed to open file \"%s\".\n", filename); logImageClose(cineon); - return 0; + return NULL; } /* not used in this case */ - cineon->memBuffer = 0; - cineon->memCursor = 0; + cineon->memBuffer = NULL; + cineon->memCursor = NULL; cineon->memBufferSize = 0; } else { @@ -175,7 +175,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t if (logimage_fread(&header, sizeof(header), 1, cineon) == 0) { if (verbose) printf("Cineon: Not enough data for header in \"%s\".\n", byteStuff); logImageClose(cineon); - return 0; + return NULL; } /* endianness determination */ @@ -191,7 +191,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t if (verbose) printf("Cineon: Bad magic number %lu in \"%s\".\n", (unsigned long)header.fileHeader.magic_num, byteStuff); logImageClose(cineon); - return 0; + return NULL; } cineon->width = swap_uint(header.imageHeader.element[0].pixels_per_line, cineon->isMSB); @@ -200,7 +200,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t if (cineon->width == 0 || cineon->height == 0) { if (verbose) printf("Cineon: Wrong image dimension: %dx%d\n", cineon->width, cineon->height); logImageClose(cineon); - return 0; + return NULL; } cineon->depth = header.imageHeader.elements_per_image; @@ -213,7 +213,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t else { if (verbose) printf("Cineon: Data interleave not supported: %d\n", header.imageHeader.interleave); logImageClose(cineon); - return 0; + return NULL; } if (cineon->depth == 1) { @@ -244,7 +244,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t else { if (verbose) printf("Cineon: Cineon image depth unsupported: %d\n", cineon->depth); logImageClose(cineon); - return 0; + return NULL; } dataOffset = swap_uint(header.fileHeader.offset, cineon->isMSB); @@ -274,7 +274,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t /* Not supported */ if (verbose) printf("Cineon: packing unsupported: %d\n", header.imageHeader.packing); logImageClose(cineon); - return 0; + return NULL; } if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refLowData)) @@ -329,20 +329,20 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t LogImageFile *cineonCreate(const char *filename, int width, int height, int bitsPerSample, const char *creator) { CineonMainHeader header; - const char *shortFilename = 0; + const char *shortFilename = NULL; /* unsigned char pad[6044]; */ LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__); - if (cineon == 0) { + if (cineon == NULL) { if (verbose) printf("cineon: Failed to malloc cineon file structure.\n"); - return 0; + return NULL; } /* Only 10 bits Cineon are supported */ if (bitsPerSample != 10) { if (verbose) printf("cineon: Only 10 bits Cineon are supported.\n"); logImageClose(cineon); - return 0; + return NULL; } cineon->width = width; @@ -366,16 +366,16 @@ LogImageFile *cineonCreate(const char *filename, int width, int height, int bits cineon->gamma = 1.7f; shortFilename = strrchr(filename, '/'); - if (shortFilename == 0) + if (shortFilename == NULL) shortFilename = filename; else shortFilename++; cineon->file = BLI_fopen(filename, "wb"); - if (cineon->file == 0) { + if (cineon->file == NULL) { if (verbose) printf("cineon: Couldn't open file %s\n", filename); logImageClose(cineon); - return 0; + return NULL; } fillCineonMainHeader(cineon, &header, shortFilename, creator); @@ -383,7 +383,7 @@ LogImageFile *cineonCreate(const char *filename, int width, int height, int bits if (fwrite(&header, sizeof(header), 1, cineon->file) == 0) { if (verbose) printf("cineon: Couldn't write image header\n"); logImageClose(cineon); - return 0; + return NULL; } return cineon; diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index 10c90b1b891..5a4371d84ba 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -76,7 +76,7 @@ static void fillDpxMainHeader(LogImageFile *dpx, DpxMainHeader *header, const ch header->fileHeader.user_data_size = DPX_UNDEFINED_U32; strncpy(header->fileHeader.file_name, filename, 99); header->fileHeader.file_name[99] = 0; - fileClock = time(0); + fileClock = time(NULL); fileTime = localtime(&fileClock); strftime(header->fileHeader.creation_date, 24, "%Y:%m:%d:%H:%M:%S%Z", fileTime); header->fileHeader.creation_date[23] = 0; @@ -138,28 +138,28 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf char *filename = (char *)byteStuff; int i; - if (dpx == 0) { + if (dpx == NULL) { if (verbose) printf("DPX: Failed to malloc dpx file structure.\n"); - return 0; + return NULL; } /* zero the header */ memset(&header, 0, sizeof(DpxMainHeader)); /* for close routine */ - dpx->file = 0; + dpx->file = NULL; if (fromMemory == 0) { /* byteStuff is then the filename */ dpx->file = BLI_fopen(filename, "rb"); - if (dpx->file == 0) { + if (dpx->file == NULL) { if (verbose) printf("DPX: Failed to open file \"%s\".\n", filename); logImageClose(dpx); - return 0; + return NULL; } /* not used in this case */ - dpx->memBuffer = 0; - dpx->memCursor = 0; + dpx->memBuffer = NULL; + dpx->memCursor = NULL; dpx->memBufferSize = 0; } else { @@ -171,7 +171,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf if (logimage_fread(&header, sizeof(header), 1, dpx) == 0) { if (verbose) printf("DPX: Not enough data for header in \"%s\".\n", byteStuff); logImageClose(dpx); - return 0; + return NULL; } /* endianness determination */ @@ -187,7 +187,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf if (verbose) printf("DPX: Bad magic number %lu in \"%s\".\n", (uintptr_t)header.fileHeader.magic_num, byteStuff); logImageClose(dpx); - return 0; + return NULL; } dpx->srcFormat = format_DPX; @@ -195,7 +195,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf if (dpx->numElements == 0) { if (verbose) printf("DPX: Wrong number of elements: %d\n", dpx->numElements); logImageClose(dpx); - return 0; + return NULL; } dpx->width = swap_uint(header.imageHeader.pixels_per_line, dpx->isMSB); @@ -204,7 +204,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf if (dpx->width == 0 || dpx->height == 0) { if (verbose) printf("DPX: Wrong image dimension: %dx%d\n", dpx->width, dpx->height); logImageClose(dpx); - return 0; + return NULL; } dpx->depth = 0; @@ -251,7 +251,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf if (dpx->depth == 0 || dpx->depth > 4) { if (verbose) printf("DPX: Unsupported image depth: %d\n", dpx->depth); logImageClose(dpx); - return 0; + return NULL; } dpx->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample; @@ -261,7 +261,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf { if (verbose) printf("DPX: Unsupported bitsPerSample for elements %d: %d\n", i, dpx->element[i].bitsPerSample); logImageClose(dpx); - return 0; + return NULL; } dpx->element[i].maxValue = powf(2, dpx->element[i].bitsPerSample) - 1.0f; @@ -270,7 +270,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf if (dpx->element[i].packing > 2) { if (verbose) printf("DPX: Unsupported packing for element %d: %d\n", i, dpx->element[i].packing); logImageClose(dpx); - return 0; + return NULL; } /* Sometimes, the offset is not set correctly in the header */ @@ -281,7 +281,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf if (dpx->element[i].dataOffset == 0) { if (verbose) printf("DPX: Image header is corrupted.\n"); logImageClose(dpx); - return 0; + return NULL; } dpx->element[i].transfer = header.imageHeader.element[i].transfer; @@ -386,13 +386,13 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer const char *creator) { DpxMainHeader header; - const char *shortFilename = 0; + const char *shortFilename = NULL; unsigned char pad[6044]; LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__); - if (dpx == 0) { + if (dpx == NULL) { if (verbose) printf("DPX: Failed to malloc dpx file structure.\n"); - return 0; + return NULL; } dpx->width = width; @@ -418,7 +418,7 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer default: if (verbose) printf("DPX: bitsPerSample not supported: %d\n", bitsPerSample); logImageClose(dpx); - return 0; + return NULL; } if (hasAlpha == 0) { @@ -463,17 +463,17 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer shortFilename = strrchr(filename, '/'); - if (shortFilename == 0) + if (shortFilename == NULL) shortFilename = filename; else shortFilename++; dpx->file = BLI_fopen(filename, "wb"); - if (dpx->file == 0) { + if (dpx->file == NULL) { if (verbose) printf("DPX: Couldn't open file %s\n", filename); logImageClose(dpx); - return 0; + return NULL; } fillDpxMainHeader(dpx, &header, shortFilename, creator); @@ -481,7 +481,7 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer if (fwrite(&header, sizeof(header), 1, dpx->file) == 0) { if (verbose) printf("DPX: Couldn't write image header\n"); logImageClose(dpx); - return 0; + return NULL; } /* Header should be rounded to next 8k block @@ -490,7 +490,7 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer if (fwrite(&pad, 6044, 1, dpx->file) == 0) { if (verbose) printf("DPX: Couldn't write image header\n"); logImageClose(dpx); - return 0; + return NULL; } return dpx; diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c index 332ad913d19..c10f201fb55 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.c +++ b/source/blender/imbuf/intern/cineon/logImageCore.c @@ -97,12 +97,12 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon) (void)cineon; - if (f == 0) - return 0; + if (f == NULL) + return NULL; if (fread(&magicNum, sizeof(unsigned int), 1, f) != 1) { fclose(f); - return 0; + return NULL; } fclose(f); @@ -112,7 +112,7 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon) else if (logImageIsCineon(&magicNum)) return cineonOpen((const unsigned char *)filename, 0, 0); - return 0; + return NULL; } LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size) @@ -122,7 +122,7 @@ LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int s else if (logImageIsCineon(buffer)) return cineonOpen(buffer, 1, size); - return 0; + return NULL; } LogImageFile *logImageCreate(const char *filename, int cineon, int width, int height, int bitsPerSample, @@ -136,15 +136,15 @@ LogImageFile *logImageCreate(const char *filename, int cineon, int width, int he return dpxCreate(filename, width, height, bitsPerSample, isLogarithmic, hasAlpha, referenceWhite, referenceBlack, gamma, creator); - return 0; + return NULL; } void logImageClose(LogImageFile *logImage) { - if (logImage != 0) { + if (logImage != NULL) { if (logImage->file) { fclose(logImage->file); - logImage->file = 0; + logImage->file = NULL; } MEM_freeN(logImage); } @@ -203,7 +203,7 @@ int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB int returnValue; elementData = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->depth * sizeof(float), __func__); - if (elementData == 0) + if (elementData == NULL) return 1; if (convertRGBAToLogElement(data, elementData, logImage, logImage->element[0], dataIsLinearRGB) != 0) { @@ -244,7 +244,7 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, int x, y; row = (unsigned char *)MEM_mallocN(rowLength, __func__); - if (row == 0) { + if (row == NULL) { if (verbose) printf("DPX/Cineon: Cannot allocate row.\n"); return 1; } @@ -272,7 +272,7 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, int x, y, offset; row = (unsigned int *)MEM_mallocN(rowLength, __func__); - if (row == 0) { + if (row == NULL) { if (verbose) printf("DPX/Cineon: Cannot allocate row.\n"); return 1; } @@ -313,7 +313,7 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, int x, y; row = (unsigned short *)MEM_mallocN(rowLength, __func__); - if (row == 0) { + if (row == NULL) { if (verbose) printf("DPX/Cineon: Cannot allocate row.\n"); return 1; } @@ -339,7 +339,7 @@ static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, int x, y; row = (unsigned short *)MEM_mallocN(rowLength, __func__); - if (row == 0) { + if (row == NULL) { if (verbose) printf("DPX/Cineon: Cannot allocate row.\n"); return 1; } @@ -383,10 +383,10 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB if (logImage->element[i].descriptor != descriptor_Depth && logImage->element[i].descriptor != descriptor_Composite) { /* Allocate memory */ elementData[i] = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->element[i].depth * sizeof(float), __func__); - if (elementData[i] == 0) { + if (elementData[i] == NULL) { if (verbose) printf("DPX/Cineon: Cannot allocate memory for elementData[%d]\n.", i); for (j = 0; j < i; j++) - if (elementData[j] != 0) + if (elementData[j] != NULL) MEM_freeN(elementData[j]); return 1; } @@ -396,7 +396,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB if (logImageElementGetData(logImage, logImage->element[i], elementData[i]) != 0) { if (verbose) printf("DPX/Cineon: Cannot read elementData[%d]\n.", i); for (j = 0; j < i; j++) - if (elementData[j] != 0) + if (elementData[j] != NULL) MEM_freeN(elementData[j]); return 1; } @@ -531,10 +531,10 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB } mergedData = (float *)MEM_mallocN(logImage->width * logImage->height * mergedElement.depth * sizeof(float), __func__); - if (mergedData == 0) { + if (mergedData == NULL) { if (verbose) printf("DPX/Cineon: Cannot allocate mergedData.\n"); for (i = 0; i < logImage->numElements; i++) - if (elementData[i] != 0) + if (elementData[i] != NULL) MEM_freeN(elementData[i]); return 1; } @@ -548,7 +548,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB /* Done with elements data, clean-up */ for (i = 0; i < logImage->numElements; i++) - if (elementData[i] != 0) + if (elementData[i] != NULL) MEM_freeN(elementData[i]); returnValue = convertLogElementToRGBA(mergedData, data, logImage, mergedElement, dataIsLinearRGB); @@ -1383,7 +1383,7 @@ static int convertRGBAToLogElement(float *src, float *dst, LogImageFile *logImag if (srcIsLinearRGB != 0) { /* we need to convert src to sRGB */ srgbSrc = (float *)MEM_mallocN(4 * logImage->width * logImage->height * sizeof(float), __func__); - if (srgbSrc == 0) + if (srgbSrc == NULL) return 1; memcpy(srgbSrc, src, 4 * logImage->width * logImage->height * sizeof(float)); diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 51619e18980..553a530ecf4 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1681,7 +1681,7 @@ static void *do_scale_thread(void *data_v) void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy) { - ScaleTreadInitData init_data = {0}; + ScaleTreadInitData init_data = {NULL}; /* prepare initialization data */ init_data.ibuf = ibuf; diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index a3d93b5437e..c9a7dc9a73d 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -76,7 +76,7 @@ static void VertexIt_Destruct(CSG_VertexIteratorDescriptor *iterator) if (iterator->it) { /* deallocate memory for iterator */ MEM_freeN(iterator->it); - iterator->it = 0; + iterator->it = NULL; } iterator->Done = NULL; iterator->Fill = NULL; @@ -127,11 +127,11 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh { VertexIt *it; - if (output == 0) return; + if (output == NULL) return; /* allocate some memory for blender iterator */ it = (VertexIt *)(MEM_mallocN(sizeof(VertexIt), "Boolean_VIt")); - if (it == 0) { + if (it == NULL) { return; } /* assign blender specific variables */ @@ -221,11 +221,11 @@ static void FaceIt_Construct( CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset, Object *ob) { FaceIt *it; - if (output == 0) return; + if (output == NULL) return; /* allocate some memory for blender iterator */ it = (FaceIt *)(MEM_mallocN(sizeof(FaceIt), "Boolean_FIt")); - if (it == 0) { + if (it == NULL) { return; } /* assign blender specific variables */ diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index f59676252d4..64435792ae2 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -97,7 +97,7 @@ static PyGetSetDef bpy_bmtexpoly_getseters[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; -PyTypeObject BPy_BMTexPoly_Type = {{{0}}}; /* bm.loops.layers.uv.active */ +static PyTypeObject BPy_BMTexPoly_Type = {{{0}}}; /* bm.loops.layers.uv.active */ static void bm_init_types_bmtexpoly(void) { diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index a1751d9717c..6f042318de2 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -441,7 +441,7 @@ PyDoc_STRVAR(app_translations_contexts_C_to_py_doc, "A readonly dict mapping contexts' C-identifiers to their py-identifiers." ); -PyMemberDef app_translations_members[] = { +static PyMemberDef app_translations_members[] = { {(char *)"contexts", T_OBJECT_EX, offsetof(BlenderAppTranslations, contexts), READONLY, app_translations_contexts_doc}, {(char *)"contexts_C_to_py", T_OBJECT_EX, offsetof(BlenderAppTranslations, contexts_C_to_py), READONLY, @@ -486,7 +486,7 @@ static PyObject *app_translations_locales_get(PyObject *UNUSED(self), void *UNUS return ret; } -PyGetSetDef app_translations_getseters[] = { +static PyGetSetDef app_translations_getseters[] = { /* {name, getter, setter, doc, userdata} */ {(char *)"locale", (getter)app_translations_locale_get, NULL, app_translations_locale_doc, NULL}, {(char *)"locales", (getter)app_translations_locales_get, NULL, app_translations_locales_doc, NULL}, @@ -637,7 +637,7 @@ static PyObject *app_translations_locale_explode(BlenderAppTranslations *UNUSED( return Py_BuildValue("sssss", language, country, variant, language_country, language_variant); } -PyMethodDef app_translations_methods[] = { +static PyMethodDef app_translations_methods[] = { /* Can't use METH_KEYWORDS alone, see http://bugs.python.org/issue11587 */ {"register", (PyCFunction)app_translations_py_messages_register, METH_VARARGS | METH_KEYWORDS, app_translations_py_messages_register_doc}, diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index d908a33c706..532404cf218 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -125,7 +125,7 @@ static void wm_free_reports(bContext *C) BKE_reports_clear(CTX_wm_reports(C)); } -int wm_start_with_console = 0; /* used in creator.c */ +bool wm_start_with_console = false; /* used in creator.c */ /* only called once, for startup */ void WM_init(bContext *C, int argc, const char **argv) diff --git a/source/creator/creator.c b/source/creator/creator.c index ba6cc728eca..768c7458ecd 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -672,10 +672,10 @@ static int without_borders(int UNUSED(argc), const char **UNUSED(argv), void *UN return 0; } -extern int wm_start_with_console; /* wm_init_exit.c */ +extern bool wm_start_with_console; /* wm_init_exit.c */ static int start_with_console(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { - wm_start_with_console = 1; + wm_start_with_console = true; return 0; } -- cgit v1.2.3