[Bf-blender-cvs] [3961d3493be] master: Cleanup: use 'u' prefixed integer types for brevity in C code
Campbell Barton
noreply at git.blender.org
Mon Sep 26 03:43:50 CEST 2022
Commit: 3961d3493be9c666850e71abe6102f72d3db9332
Author: Campbell Barton
Date: Mon Sep 26 10:56:05 2022 +1000
Branches: master
https://developer.blender.org/rB3961d3493be9c666850e71abe6102f72d3db9332
Cleanup: use 'u' prefixed integer types for brevity in C code
This also simplifies using function style casts when moving to C++.
===================================================================
M intern/guardedalloc/intern/mallocn_guarded_impl.c
M source/blender/blendthumb/src/blendthumb_win32.cc
M source/blender/blenfont/intern/blf_font_win32_compat.c
M source/blender/blenfont/intern/blf_thumbs.c
M source/blender/blenkernel/intern/cloth.c
M source/blender/blenkernel/intern/collision.c
M source/blender/blenkernel/intern/colortools.c
M source/blender/blenkernel/intern/constraint.c
M source/blender/blenkernel/intern/customdata_file.c
M source/blender/blenkernel/intern/deform.c
M source/blender/blenkernel/intern/dynamicpaint.c
M source/blender/blenkernel/intern/editmesh_bvh.c
M source/blender/blenkernel/intern/fcurve.c
M source/blender/blenkernel/intern/gpencil.c
M source/blender/blenkernel/intern/gpencil_curve.c
M source/blender/blenkernel/intern/image_gen.c
M source/blender/blenkernel/intern/ipo.c
M source/blender/blenkernel/intern/layer.c
M source/blender/blenkernel/intern/mask_evaluate.c
M source/blender/blenkernel/intern/mask_rasterize.c
M source/blender/blenkernel/intern/mball_tessellate.c
M source/blender/blenkernel/intern/mesh_remap.c
M source/blender/blenkernel/intern/object_deform.c
M source/blender/blenkernel/intern/ocean.c
M source/blender/blenkernel/intern/pointcache.c
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/blenkernel/intern/sound.c
M source/blender/blenkernel/intern/subsurf_ccg.c
M source/blender/blenkernel/intern/text.c
M source/blender/blenkernel/intern/tracking.c
M source/blender/blenkernel/intern/tracking_detect.c
M source/blender/blenkernel/intern/tracking_util.c
M source/blender/blenkernel/intern/vfont.c
M source/blender/blenkernel/intern/vfontdata_freetype.c
M source/blender/blenkernel/intern/writeavi.c
M source/blender/blenkernel/intern/writeffmpeg.c
M source/blender/blenlib/intern/BLI_filelist.c
M source/blender/blenlib/intern/BLI_memarena.c
M source/blender/blenlib/intern/array_store.c
M source/blender/blenlib/intern/convexhull_2d.c
M source/blender/blenlib/intern/hash_mm3.c
M source/blender/blenlib/intern/math_geom.c
M source/blender/blenlib/intern/math_interp.c
M source/blender/blenlib/intern/noise.c
M source/blender/blenlib/intern/scanfill.c
M source/blender/blenlib/intern/scanfill_utils.c
M source/blender/blenlib/intern/stack.c
M source/blender/blenlib/intern/string.c
M source/blender/blenlib/intern/string_utf8.c
M source/blender/blenlib/intern/system.c
M source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
M source/blender/editors/space_sequencer/sequencer_thumbnails.c
M source/blender/io/avi/intern/avi.c
M source/blender/io/avi/intern/avi_mjpeg.c
M source/blender/io/avi/intern/avi_mjpeg.h
M source/blender/makesdna/intern/dna_genfile.c
M source/blender/makesrna/intern/rna_ID.c
M source/blender/makesrna/intern/rna_image.c
M source/blender/makesrna/intern/rna_mesh.c
M source/blender/makesrna/intern/rna_rna.c
M source/blender/makesrna/intern/rna_test.c
M source/blender/modifiers/intern/MOD_surfacedeform.c
M source/blender/render/intern/multires_bake.c
M source/blender/sequencer/intern/effects.c
M source/blender/sequencer/intern/modifier.c
M source/blender/sequencer/intern/render.c
M source/blender/simulation/intern/implicit_blender.c
M source/blender/windowmanager/intern/wm_window.c
M source/blender/windowmanager/xr/intern/wm_xr_action.c
M source/blender/windowmanager/xr/intern/wm_xr_draw.c
M source/blender/windowmanager/xr/intern/wm_xr_session.c
===================================================================
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index cd4b99ecde8..8deeb862b35 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -144,7 +144,7 @@ static const char *check_memlist(MemHead *memh);
/* vars */
/* --------------------------------------------------------------------- */
-static unsigned int totblock = 0;
+static uint totblock = 0;
static size_t mem_in_use = 0, peak_mem = 0;
static volatile struct localListBase _membase;
@@ -453,7 +453,7 @@ void *MEM_guarded_mallocN(size_t len, const char *str)
print_error("Malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -467,7 +467,7 @@ void *MEM_guarded_malloc_arrayN(size_t len, size_t size, const char *str)
SIZET_ARG(len),
SIZET_ARG(size),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
abort();
return NULL;
}
@@ -526,7 +526,7 @@ void *MEM_guarded_mallocN_aligned(size_t len, size_t alignment, const char *str)
print_error("aligned_malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -550,7 +550,7 @@ void *MEM_guarded_callocN(size_t len, const char *str)
print_error("Calloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -564,7 +564,7 @@ void *MEM_guarded_calloc_arrayN(size_t len, size_t size, const char *str)
SIZET_ARG(len),
SIZET_ARG(size),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
abort();
return NULL;
}
@@ -606,7 +606,7 @@ void MEM_guarded_printmemlist_stats(void)
{
MemHead *membl;
MemPrintBlock *pb, *printblock;
- unsigned int totpb, a, b;
+ uint totpb, a, b;
size_t mem_in_use_slop = 0;
mem_lock_thread();
@@ -1177,9 +1177,9 @@ size_t MEM_guarded_get_memory_in_use(void)
return _mem_in_use;
}
-unsigned int MEM_guarded_get_memory_blocks_in_use(void)
+uint MEM_guarded_get_memory_blocks_in_use(void)
{
- unsigned int _totblock;
+ uint _totblock;
mem_lock_thread();
_totblock = totblock;
diff --git a/source/blender/blendthumb/src/blendthumb_win32.cc b/source/blender/blendthumb/src/blendthumb_win32.cc
index 4ba91955bd3..206309b6caf 100644
--- a/source/blender/blendthumb/src/blendthumb_win32.cc
+++ b/source/blender/blendthumb/src/blendthumb_win32.cc
@@ -172,10 +172,10 @@ IFACEMETHODIMP CBlendThumb::GetThumbnail(UINT cx, HBITMAP *phbmp, WTS_ALPHATYPE
*pdwAlpha = WTSAT_ARGB;
/* Scale up the thumbnail if required. */
- if ((unsigned)thumb.width < cx && (unsigned)thumb.height < cx) {
+ if (uint(thumb.width) < cx && uint(thumb.height) < cx) {
float scale = 1.0f / (std::max(thumb.width, thumb.height) / float(cx));
- LONG NewWidth = (LONG)(thumb.width * scale);
- LONG NewHeight = (LONG)(thumb.height * scale);
+ LONG NewWidth = LONG(thumb.width * scale);
+ LONG NewHeight = LONG(thumb.height * scale);
IWICImagingFactory *pImgFac;
hr = CoCreateInstance(
diff --git a/source/blender/blenfont/intern/blf_font_win32_compat.c b/source/blender/blenfont/intern/blf_font_win32_compat.c
index 17213275c74..4bb2a010dd9 100644
--- a/source/blender/blenfont/intern/blf_font_win32_compat.c
+++ b/source/blender/blenfont/intern/blf_font_win32_compat.c
@@ -39,10 +39,7 @@ static void ft_ansi_stream_close(FT_Stream stream)
MEM_freeN(stream);
}
-static unsigned long ft_ansi_stream_io(FT_Stream stream,
- unsigned long offset,
- unsigned char *buffer,
- unsigned long count)
+static ulong ft_ansi_stream_io(FT_Stream stream, ulong offset, uchar *buffer, ulong count)
{
FILE *file;
if (!count && offset > stream->size) {
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c
index 110ef97fd3a..2eed7418220 100644
--- a/source/blender/blenfont/intern/blf_thumbs.c
+++ b/source/blender/blenfont/intern/blf_thumbs.c
@@ -283,8 +283,7 @@ static const char32_t *blf_get_sample_text(FT_Face face)
return sample;
}
-bool BLF_thumb_preview(
- const char *filename, unsigned char *buf, int w, int h, int UNUSED(channels))
+bool BLF_thumb_preview(const char *filename, uchar *buf, int w, int h, int UNUSED(channels))
{
/* Use own FT_Library and direct FreeType calls as this is called from multiple threads. */
FT_Library ft_lib = NULL;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 8c3098069c4..e85e19f04c9 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -1148,7 +1148,7 @@ static void cloth_update_springs(ClothModifierData *clmd)
/* Update rest verts, for dynamically deformable cloth */
static void cloth_update_verts(Object *ob, ClothModifierData *clmd, Mesh *mesh)
{
- unsigned int i = 0;
+ uint i = 0;
const MVert *mvert = BKE_mesh_verts(mesh);
ClothVertex *verts = clmd->clothObject->verts;
@@ -1180,9 +1180,9 @@ static void cloth_update_spring_lengths(ClothModifierData *clmd, Mesh *mesh)
{
Cloth *cloth = clmd->clothObject;
LinkNode *search = cloth->springs;
- unsigned int struct_springs = 0;
- unsigned int i = 0;
- unsigned int mvert_num = (unsigned int)mesh->totvert;
+ uint struct_springs = 0;
+ uint i = 0;
+ uint mvert_num = (uint)mesh->totvert;
float shrink_factor;
clmd->sim_parms->avg_spring_len = 0.0f;
@@ -1373,12 +1373,12 @@ BLI_INLINE bool cloth_bend_set_poly_vert_array(int **poly, int len, const MLoop
}
static bool find_internal_spring_target_vertex(BVHTreeFromMesh *treedata,
- unsigned int v_idx,
+ uint v_idx,
RNG *rng,
float max_length,
float max_diversion,
bool check_normal,
- unsigned int *r_tar_v_idx)
+ uint *r_tar_v_idx)
{
float co[3], no[3], new_co[3];
float radius;
@@ -1415,7 +1415,7 @@ static bool find_internal_spring_target_vertex(BVHTreeFromMesh *treedata,
BLI_bvhtree_ray_cast(
treedata->tree, new_co, no, radius, &rayhit, treedata->raycast_callback, treedata);
- unsigned int vert_idx = -1;
+ uint vert_idx = -1;
const MLoop *mloop = treedata->loop;
const MLoopTri *lt = NULL;
@@ -1429,7 +1429,7 @@ static bool find_internal_spring_target_vertex(BVHTreeFromMesh *treedata,
lt = &treedata->looptri[rayhit.index];
for (int i = 0; i < 3; i++) {
- unsigned int tmp_vert_idx = mloop[lt->tri[i]].v;
+ uint tmp_vert_idx = mloop[lt->tri[i]].v;
if (tmp_vert_idx == v_idx) {
/* We managed to hit ourselves. */
return false;
@@ -1453,10 +1453,10 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
{
Cloth *cloth = clmd->clothObject;
ClothSpring *spring = NULL, *tspring = NULL, *tspring2 = NULL;
- unsigned int struct_springs = 0, shear_springs = 0, bend_springs = 0, struct_springs_real = 0;
- unsigned int mvert_num = (unsigned int)mesh->totvert;
- unsigned int numedges = (unsigned int)mesh->totedge;
- unsigned int numpolys = (unsigned int)mesh->totpoly;
+ uint struct_springs = 0, shear_springs = 0, bend_springs = 0, struct_springs_real = 0;
+ uint mvert_num = (uint)mesh->totvert;
+ uint numedges = (uint)mesh->totedge;
+ uint numpolys = (uint)mesh->totpoly;
float shrink_factor;
const MEdge *medge = BKE_mesh_edges(mesh);
const MPoly *mpoly = BKE_mesh_polys(mesh);
@@ -1499,7 +1499,7 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
if (use_internal_springs && numpolys > 0) {
BVHTreeFromMesh treedata = {NULL};
- unsigned int tar_v_idx;
+ uint tar_v_idx;
Mesh *tmp_mesh = NULL;
RNG *rng;
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index dc7a4968f59..2acdc6543b5 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1216,10 +1216,7 @@ static void hair_collision(void *__restrict userdata,
}
}
-static void add_collision_object(ListBase *relations,
- Object *ob,
- int level,
- unsigned int modifier_type)
+static void add_collision_object(ListBase *relations, Object *ob, int level, uint modifier_type)
{
/* only get objects with collision modifier */
ModifierData *cmd = BKE_modifiers_findby_type(ob, modifier_type);
@@ -1246,7 +1243,7 @@ static void add_collision_object(ListBase *relations,
ListBase *BKE_collision_relations_create(Depsgraph *depsgraph,
Collection *collection,
- unsigned int modifier_type)
+ uint modifier_type)
{
const Scene *scene = DEG_get_input_scene(depsgraph);
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
@@ -1276,8 +1273,8 @@ void BKE_collision_relations_free(ListBase *relations)
Object **BKE_collision_objects_create(Depsgraph *depsgraph,
Object *self,
Collection *collection,
- unsigned int *numcollobj,
- unsigned int modifier_type)
+ uint *numcollob
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list