diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-06 02:50:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-06 02:50:55 +0300 |
commit | 2f366d1544ecc5618d7190b779ccc75f2f144d0a (patch) | |
tree | 699c5b52c7f8768bd46720b1824bee3565e2dff9 /source/blender/editors | |
parent | 9668c29ba00ed830109665ea132b6292cdfe9e2a (diff) |
use BLI_strnlen rather then strlen when comparing against fixed lengths.
Diffstat (limited to 'source/blender/editors')
4 files changed, 13 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index b62a76ee14a..ab0ee09fb4e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2357,7 +2357,7 @@ for float buttons: static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - short slen; + int slen; if(type & BUTPOIN) { /* a pointer is required */ if(poin==NULL) @@ -2374,14 +2374,16 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->iconadd=0; but->retval= retval; - if( strlen(str)>=UI_MAX_NAME_STR-1 ) { - but->str= MEM_callocN( strlen(str)+2, "uiDefBut"); - strcpy(but->str, str); + + slen= strlen(str); + if(slen >= UI_MAX_NAME_STR-1) { + but->str= MEM_mallocN(slen+2, "ui_def_but str"); /* why +2 ? */ } else { but->str= but->strdata; - strcpy(but->str, str); } + memcpy(but->str, str, slen+1); + but->x1= x1; but->y1= y1; but->x2= (x1+x2); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 35aa351dc20..1e963e37fd2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1316,10 +1316,11 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction } else { if(select) { /* make a selection, starting from the cursor position */ + int tlen; but->selsta = but->pos; but->pos++; - if(but->pos>strlen(str)) but->pos= strlen(str); + if(but->pos > (tlen= strlen(str))) but->pos= tlen; but->selend = but->pos; } else if(jump) { @@ -1331,8 +1332,9 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction if(test_special_char(str[but->pos])) break; } } else { + int tlen; but->pos++; - if(but->pos>strlen(str)) but->pos= strlen(str); + if(but->pos > (tlen= strlen(str))) but->pos= tlen; } } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 8533e5ba893..cf1a90137af 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -507,7 +507,7 @@ static void init_internal_icons(void) int x, y, icontype; char iconfilestr[FILE_MAXDIR+FILE_MAXFILE]; - if ((btheme!=NULL) && (strlen(btheme->tui.iconfile) > 0)) { + if ((btheme!=NULL) && btheme->tui.iconfile[0]) { char *datadir= BLI_get_folder(BLENDER_DATAFILES, NULL); if (datadir) { BLI_make_file_string("/", iconfilestr, datadir, btheme->tui.iconfile); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 1801116fe01..da8e7e063f4 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -665,7 +665,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // invalid dir, reset to current/previous strcpy(blendDir, G.main->name); BLI_splitdirstring(blendDir, blendFile); - if(strlen(blendFile)>6){ + if(BLI_strnlen(blendFile, 7) > 6){ int len = strlen(blendFile); if( (blendFile[len-6]=='.')&& (blendFile[len-5]=='b')&& (blendFile[len-4]=='l')&& (blendFile[len-3]=='e')&& (blendFile[len-2]=='n')&& (blendFile[len-1]=='d') ){ |