Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-25 16:40:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-03-25 16:40:44 +0300
commit77a1a2f14e969176133d53a1504dc0f0b92e8b00 (patch)
tree52a265fcb0ecc2d0bdacdb42e34bfd28797d407f /source
parent21e0eff89712435708d4c8d931e988777a9f865a (diff)
use size_t rather then int for passing lengths to string functions since this is what guarded-malloc uses as well as stdlib.h.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/BLI_string.h8
-rw-r--r--source/blender/blenlib/intern/string.c24
2 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 4694f4c413f..635c38e1d13 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -58,7 +58,7 @@ char *BLI_strdup(const char *str);
* @param len The number of bytes to duplicate
* @retval Returns the duplicated string
*/
-char *BLI_strdupn(const char *str, int len);
+char *BLI_strdupn(const char *str, const size_t len);
/**
* Appends the two strings, and returns new mallocN'ed string
@@ -78,7 +78,7 @@ char *BLI_strdupcat(const char *str1, const char *str2);
* the size of dst)
* @retval Returns dst
*/
-char *BLI_strncpy(char *dst, const char *src, const int maxncpy);
+char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy);
/* Makes a copy of the text within the "" that appear after some text 'blahblah'
* i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
@@ -106,7 +106,7 @@ char *BLI_replacestr(char *str, const char *oldText, const char *newText);
/*
* Replacement for snprintf
*/
-int BLI_snprintf(char *buffer, size_t count, const char *format, ...)
+size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 3, 4)))
#endif
@@ -138,7 +138,7 @@ int BLI_strcaseeq(const char *a, const char *b);
char *BLI_strcasestr(const char *s, const char *find);
int BLI_strcasecmp(const char *s1, const char *s2);
-int BLI_strncasecmp(const char *s1, const char *s2, int n);
+int BLI_strncasecmp(const char *s1, const char *s2, size_t len);
int BLI_natstrcmp(const char *s1, const char *s2);
size_t BLI_strnlen(const char *str, size_t maxlen);
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 259c12781f2..d626ca4bf09 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -47,7 +47,7 @@
#include "BLI_dynstr.h"
#include "BLI_string.h"
-char *BLI_strdupn(const char *str, int len) {
+char *BLI_strdupn(const char *str, const size_t len) {
char *n= MEM_mallocN(len+1, "strdup");
memcpy(n, str, len);
n[len]= '\0';
@@ -60,7 +60,7 @@ char *BLI_strdup(const char *str) {
char *BLI_strdupcat(const char *str1, const char *str2)
{
- int len;
+ size_t len;
char *n;
len= strlen(str1)+strlen(str2);
@@ -71,9 +71,9 @@ char *BLI_strdupcat(const char *str1, const char *str2)
return n;
}
-char *BLI_strncpy(char *dst, const char *src, const int maxncpy) {
- int srclen= strlen(src);
- int cpylen= (srclen>(maxncpy-1))?(maxncpy-1):srclen;
+char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy) {
+ size_t srclen= strlen(src);
+ size_t cpylen= (srclen>(maxncpy-1))?(maxncpy-1):srclen;
memcpy(dst, src, cpylen);
dst[cpylen]= '\0';
@@ -81,9 +81,9 @@ char *BLI_strncpy(char *dst, const char *src, const int maxncpy) {
return dst;
}
-int BLI_snprintf(char *buffer, size_t count, const char *format, ...)
+size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...)
{
- int n;
+ size_t n;
va_list arg;
va_start(arg, format);
@@ -128,7 +128,7 @@ char *BLI_sprintfN(const char *format, ...)
*/
char *BLI_getQuotedStr (const char *str, const char *prefix)
{
- int prefixLen = strlen(prefix);
+ size_t prefixLen = strlen(prefix);
char *startMatch, *endMatch;
/* get the starting point (i.e. where prefix starts, and add prefixLen+1 to it to get be after the first " */
@@ -138,7 +138,7 @@ char *BLI_getQuotedStr (const char *str, const char *prefix)
endMatch= strchr(startMatch, '"'); // " NOTE: this comment here is just so that my text editor still shows the functions ok...
/* return the slice indicated */
- return BLI_strdupn(startMatch, (int)(endMatch-startMatch));
+ return BLI_strdupn(startMatch, (size_t)(endMatch-startMatch));
}
/* Replaces all occurances of oldText with newText in str, returning a new string that doesn't
@@ -149,7 +149,7 @@ char *BLI_getQuotedStr (const char *str, const char *prefix)
char *BLI_replacestr(char *str, const char *oldText, const char *newText)
{
DynStr *ds= NULL;
- int lenOld= strlen(oldText);
+ size_t lenOld= strlen(oldText);
char *match;
/* sanity checks */
@@ -263,10 +263,10 @@ int BLI_strcasecmp(const char *s1, const char *s2) {
return 0;
}
-int BLI_strncasecmp(const char *s1, const char *s2, int n) {
+int BLI_strncasecmp(const char *s1, const char *s2, size_t len) {
int i;
- for (i=0; i<n; i++) {
+ for (i=0; i<len; i++) {
char c1 = tolower(s1[i]);
char c2 = tolower(s2[i]);