[Bf-blender-cvs] [f489e0c] master: Code Cleanup: remove strlen() and unneeded include in recent commit

Campbell Barton noreply at git.blender.org
Fri Jan 3 09:41:13 CET 2014


Commit: f489e0c14cbf852472a2c89328c37adfe4b9f21c
Author: Campbell Barton
Date:   Fri Jan 3 19:31:52 2014 +1100
https://developer.blender.org/rBf489e0c14cbf852472a2c89328c37adfe4b9f21c

Code Cleanup: remove strlen() and unneeded include in recent commit

also fix for incorrect sizeof() use.

===================================================================

M	source/blender/editors/interface/interface_widgets.c

===================================================================

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index bffb1b6..6139130 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -33,8 +33,6 @@
 #include <string.h>
 #include <assert.h>
 
-#include "MEM_guardedalloc.h"
-
 #include "DNA_screen_types.h"
 #include "DNA_userdef_types.h"
 
@@ -987,13 +985,13 @@ static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti *rec
 	strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
 
 	if (strwidth > okwidth) {
-		const char *sep = "...";
-		const int sep_len = strlen(sep);
+		const char sep[] = "...";
+		const int sep_len = sizeof(sep) - 1;
 
 		const size_t max_len = sizeof(but->drawstr);
 		size_t l_end;
 
-		const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sizeof(sep));
+		const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1);
 		const float parts_strwidth = ((float)okwidth - sep_strwidth) / 2.0f;
 
 		if (parts_strwidth < (float)UI_DPI_ICON_SIZE) {




More information about the Bf-blender-cvs mailing list