summaryrefslogtreecommitdiff
path: root/Ivy/DataTypes.h
diff options
context:
space:
mode:
authorfcolin2007-02-01 12:54:32 +0000
committerfcolin2007-02-01 12:54:32 +0000
commite66ce001f6b6ff89fa0804d167d16e73f12a5d4b (patch)
tree9324ec8010f185b469edbfbd61425a76811a693b /Ivy/DataTypes.h
parent8d5a7b300f69298500e97762987ccd36174c288a (diff)
downloadivy-cplusplus-e66ce001f6b6ff89fa0804d167d16e73f12a5d4b.zip
ivy-cplusplus-e66ce001f6b6ff89fa0804d167d16e73f12a5d4b.tar.gz
ivy-cplusplus-e66ce001f6b6ff89fa0804d167d16e73f12a5d4b.tar.bz2
ivy-cplusplus-e66ce001f6b6ff89fa0804d167d16e73f12a5d4b.tar.xz
Utilisateur : Fcolin Date : 16/11/05 Heure : 9:54 Archivé dans $/Bus/Ivy Commentaire: 64 bits ports (vss 11)
Diffstat (limited to 'Ivy/DataTypes.h')
-rw-r--r--Ivy/DataTypes.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/Ivy/DataTypes.h b/Ivy/DataTypes.h
index 190a7a6..280c2de 100644
--- a/Ivy/DataTypes.h
+++ b/Ivy/DataTypes.h
@@ -10,7 +10,7 @@
#endif
#include <string.h>
-
+#include <string>
namespace ivy
{
@@ -39,17 +39,19 @@ public:
{
if ( ptr ) delete [] ptr;
ptr = allocBuffer( len );
- strncpy( ptr, s, len );
+ strncpy_s( ptr, len + 1, s, len );
}
void erase(size_t start=0, size_t len = npos)
{
char *newptr;
size_t real_len;
+ size_t buf_size;
real_len = len == npos ? size - start : len;
if ( real_len > size ) real_len = size;
- newptr = allocBuffer( size - real_len );
- strncpy( newptr, ptr , start );
- strncpy( &newptr[start], &ptr[start+real_len], size - start );
+ buf_size = size - real_len;
+ newptr = allocBuffer( buf_size );
+ strncpy_s( newptr, buf_size +1, ptr , start );
+ strncpy_s( &newptr[start], buf_size +1 - start, &ptr[start+real_len], size - start );
delete ptr;
ptr = newptr;
}
@@ -61,10 +63,11 @@ public:
{
char *newptr;
if ( len == npos ) len = strlen(s) ;
- newptr = allocBuffer( size + len );
- strncpy( newptr , ptr, index );
- strncpy( newptr+index , s, len ) ;
- strncpy( newptr+index+len , &ptr[index], size - (index+len) ) ;
+ size_t buf_len = size + len;
+ newptr = allocBuffer( buf_len );
+ strncpy_s( newptr , buf_len +1, ptr, index );
+ strncpy_s( newptr+index, buf_len + 1 - index, s, len ) ;
+ strncpy_s( newptr+index+len, buf_len + 1 - index -len, &ptr[index], size - (index+len) ) ;
delete ptr;
ptr = newptr;
}