Changeset 3530 in orxonox.OLD for orxonox/branches/levelloader/src/lib/util
- Timestamp:
- Mar 13, 2005, 10:40:25 PM (20 years ago)
- Location:
- orxonox/branches/levelloader/src/lib/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/lib/util/substring.cc
r3525 r3530 22 22 #include "substring.h" 23 23 24 SubString::SubString( c har* string)24 SubString::SubString( const char* string) 25 25 { 26 26 n = 0; … … 32 32 n += 1; 33 33 34 strings = malloc( sizeof( char*) * n);34 strings = new char*[n]; 35 35 36 36 int i = 0; 37 37 int l = 0; 38 38 39 c har* offset = string;39 const char* offset = string; 40 40 char* end = strchr( string, ','); 41 41 while( end != NULL) 42 42 { 43 43 l = end - offset; 44 strings[i] = malloc( l + 1);44 strings[i] = new char[l + 1]; 45 45 strncpy( strings[i], offset, l); 46 46 i++; … … 50 50 } 51 51 52 strings[i] = malloc( l + 1);52 strings[i] = new char[l + 1]; 53 53 strncpy( strings[i], offset, l); 54 54 l = strlen( offset); … … 62 62 for( int i = 0; i < n; i++) 63 63 { 64 free( strings[i]);64 delete strings[i]; 65 65 } 66 66 67 free( strings);67 delete strings; 68 68 } 69 69 -
orxonox/branches/levelloader/src/lib/util/substring.h
r3525 r3530 3 3 \brief a small class to get the parts of a string separated by commas 4 4 */ 5 6 #ifndef _SUBSTRING_H 7 #define _SUBSTRING_H 5 8 6 9 #include "stdincl.h" … … 10 13 public: 11 14 12 SubString( c har* string);15 SubString( const char* string); 13 16 ~SubString(); 14 17 … … 20 23 int n; 21 24 }; 25 26 #endif /* _SUBSTRING_H */
Note: See TracChangeset
for help on using the changeset viewer.