Use ARRAY_SIZE to replace (sizeof(a) / sizeof(*a))
This commit is contained in:
		@@ -107,7 +107,7 @@ static PyStructSequence_Desc app_info_desc = {
 | 
			
		||||
	(char *)"bpy.app",     /* name */
 | 
			
		||||
	(char *)"This module contains application values that remain unchanged during runtime.",    /* doc */
 | 
			
		||||
	app_info_fields,    /* fields */
 | 
			
		||||
	(sizeof(app_info_fields) / sizeof(PyStructSequence_Field)) - 1
 | 
			
		||||
	ARRAY_SIZE(app_info_fields) - 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static PyObject *make_app_info(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,8 @@
 | 
			
		||||
 | 
			
		||||
#include <Python.h>
 | 
			
		||||
 | 
			
		||||
#include "BLI_utildefines.h"
 | 
			
		||||
 | 
			
		||||
#include "bpy_app_build_options.h"
 | 
			
		||||
 | 
			
		||||
static PyTypeObject BlenderAppBuildOptionsType;
 | 
			
		||||
@@ -74,7 +76,7 @@ static PyStructSequence_Desc app_builtopts_info_desc = {
 | 
			
		||||
	(char *)"bpy.app.build_options",     /* name */
 | 
			
		||||
	(char *)"This module contains information about options blender is built with",    /* doc */
 | 
			
		||||
	app_builtopts_info_fields,    /* fields */
 | 
			
		||||
	(sizeof(app_builtopts_info_fields) / sizeof(PyStructSequence_Field)) - 1
 | 
			
		||||
	ARRAY_SIZE(app_builtopts_info_fields) - 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static PyObject *make_builtopts_info(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,7 @@ static PyStructSequence_Desc app_ffmpeg_info_desc = {
 | 
			
		||||
	(char *)"bpy.app.ffmpeg",     /* name */
 | 
			
		||||
	(char *)"This module contains information about FFmpeg blender is linked against",    /* doc */
 | 
			
		||||
	app_ffmpeg_info_fields,    /* fields */
 | 
			
		||||
	(sizeof(app_ffmpeg_info_fields) / sizeof(PyStructSequence_Field)) - 1
 | 
			
		||||
	ARRAY_SIZE(app_ffmpeg_info_fields) - 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static PyObject *make_ffmpeg_info(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -71,11 +71,11 @@ static PyStructSequence_Desc app_cb_info_desc = {
 | 
			
		||||
	(char *)"bpy.app.handlers",     /* name */
 | 
			
		||||
	(char *)"This module contains callbacks",    /* doc */
 | 
			
		||||
	app_cb_info_fields,    /* fields */
 | 
			
		||||
	(sizeof(app_cb_info_fields) / sizeof(PyStructSequence_Field)) - 1
 | 
			
		||||
	ARRAY_SIZE(app_cb_info_fields) - 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
#  if (BLI_CB_EVT_TOT != ((sizeof(app_cb_info_fields) / sizeof(PyStructSequence_Field))))
 | 
			
		||||
#  if (BLI_CB_EVT_TOT != ARRAY_SIZE(app_cb_info_fields))
 | 
			
		||||
#    error "Callbacks are out of sync"
 | 
			
		||||
#  endif
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,7 @@ static PyStructSequence_Desc app_ocio_info_desc = {
 | 
			
		||||
	(char *)"bpy.app.ocio",     /* name */
 | 
			
		||||
	(char *)"This module contains information about OpenColorIO blender is linked against",    /* doc */
 | 
			
		||||
	app_ocio_info_fields,    /* fields */
 | 
			
		||||
	(sizeof(app_ocio_info_fields) / sizeof(PyStructSequence_Field)) - 1
 | 
			
		||||
	ARRAY_SIZE(app_ocio_info_fields) - 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static PyObject *make_ocio_info(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,7 @@ static PyStructSequence_Desc app_oiio_info_desc = {
 | 
			
		||||
	(char *)"bpy.app.oiio",     /* name */
 | 
			
		||||
	(char *)"This module contains information about OpeImageIO blender is linked against",    /* doc */
 | 
			
		||||
	app_oiio_info_fields,    /* fields */
 | 
			
		||||
	(sizeof(app_oiio_info_fields) / sizeof(PyStructSequence_Field)) - 1
 | 
			
		||||
	ARRAY_SIZE(app_oiio_info_fields) - 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static PyObject *make_oiio_info(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -390,13 +390,13 @@ static BLF_i18n_contexts_descriptor _contexts[] = BLF_I18NCONTEXTS_DESC;
 | 
			
		||||
 * This allows us to avoid many handwriting, and above all, to keep all context definition stuff in BLF_translation.h!
 | 
			
		||||
 */
 | 
			
		||||
static PyStructSequence_Field
 | 
			
		||||
app_translations_contexts_fields[sizeof(_contexts) / sizeof(BLF_i18n_contexts_descriptor)] = {{NULL}};
 | 
			
		||||
app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = {{NULL}};
 | 
			
		||||
 | 
			
		||||
static PyStructSequence_Desc app_translations_contexts_desc = {
 | 
			
		||||
	(char *)"bpy.app.translations.contexts",     /* name */
 | 
			
		||||
	(char *)"This named tuple contains all pre-defined translation contexts",    /* doc */
 | 
			
		||||
	app_translations_contexts_fields,    /* fields */
 | 
			
		||||
	(sizeof(app_translations_contexts_fields) / sizeof(PyStructSequence_Field)) - 1
 | 
			
		||||
	ARRAY_SIZE(app_translations_contexts_fields) - 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static PyObject *app_translations_contexts_make(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -243,7 +243,7 @@ void BPY_python_start(int argc, const char **argv)
 | 
			
		||||
 | 
			
		||||
	/* not essential but nice to set our name */
 | 
			
		||||
	static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */
 | 
			
		||||
	BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t));
 | 
			
		||||
	BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), ARRAY_SIZE(program_path_wchar));
 | 
			
		||||
	Py_SetProgramName(program_path_wchar);
 | 
			
		||||
 | 
			
		||||
	/* must run before python initializes */
 | 
			
		||||
 
 | 
			
		||||
@@ -69,12 +69,12 @@ void bpy_intern_string_init(void)
 | 
			
		||||
 | 
			
		||||
#undef BPY_INTERN_STR
 | 
			
		||||
 | 
			
		||||
	BLI_assert(i == (sizeof(bpy_intern_str_arr) / sizeof(*bpy_intern_str_arr)));
 | 
			
		||||
	BLI_assert(i == ARRAY_SIZE(bpy_intern_str_arr));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void bpy_intern_string_exit(void)
 | 
			
		||||
{
 | 
			
		||||
	unsigned int i = sizeof(bpy_intern_str_arr) / sizeof(*bpy_intern_str_arr);
 | 
			
		||||
	unsigned int i = ARRAY_SIZE(bpy_intern_str_arr);
 | 
			
		||||
	while (i--) {
 | 
			
		||||
		Py_DECREF(bpy_intern_str_arr[i]);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user