Replace Maxsi::String::Length with strlen.

This commit is contained in:
Jonas 'Sortie' Termansen 2012-09-22 22:40:44 +02:00
parent 5e7bf8527c
commit 5e4dadbba0
11 changed files with 23 additions and 22 deletions

View File

@ -25,6 +25,7 @@
#include <libmaxsi/platform.h> #include <libmaxsi/platform.h>
#include <libmaxsi/string.h> #include <libmaxsi/string.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
namespace Maxsi namespace Maxsi
{ {
@ -309,7 +310,7 @@ namespace Maxsi
{ {
READY_FLUSH(); READY_FLUSH();
const char* str = va_arg(parameters, const char*); const char* str = va_arg(parameters, const char*);
size_t len = String::Length(str); size_t len = strlen(str);
if ( callback && callback(user, str, len) != len ) { return SIZE_MAX; } if ( callback && callback(user, str, len) != len ) { return SIZE_MAX; }
written += len; written += len;
break; break;

View File

@ -95,7 +95,7 @@ namespace Sortix
const char* wd = process->workingdir; const char* wd = process->workingdir;
char* abs = MakeAbsolute(wd, path); char* abs = MakeAbsolute(wd, path);
if ( !abs ) { errno = ENOMEM; return -1; } if ( !abs ) { errno = ENOMEM; return -1; }
size_t abslen = String::Length(abs); size_t abslen = strlen(abs);
if ( 1 < abslen && abs[abslen-1] == '/' ) if ( 1 < abslen && abs[abslen-1] == '/' )
{ {
abs[abslen-1] = '\0'; abs[abslen-1] = '\0';
@ -122,7 +122,7 @@ namespace Sortix
Process* process = CurrentProcess(); Process* process = CurrentProcess();
const char* wd = process->workingdir; const char* wd = process->workingdir;
if ( !wd ) { wd = "/"; } if ( !wd ) { wd = "/"; }
size_t wdsize = String::Length(wd) + 1; size_t wdsize = strlen(wd) + 1;
if ( size < wdsize ) { errno = ERANGE; return NULL; } if ( size < wdsize ) { errno = ERANGE; return NULL; }
String::Copy(buf, wd); String::Copy(buf, wd);
return buf; return buf;
@ -142,8 +142,8 @@ namespace Sortix
if ( !wd ) { wd = "/"; } if ( !wd ) { wd = "/"; }
// The resulting size won't ever be larger than this. // The resulting size won't ever be larger than this.
size_t wdlen = String::Length(wd); size_t wdlen = strlen(wd);
size_t resultsize = wdlen + String::Length(rel) + 2; size_t resultsize = wdlen + strlen(rel) + 2;
char* result = new char[resultsize + 1]; char* result = new char[resultsize + 1];
if ( !result ) { return NULL; } if ( !result ) { return NULL; }

View File

@ -324,7 +324,7 @@ namespace Sortix
if ( available <= sizeof(sortix_dirent) ) { return -1; } if ( available <= sizeof(sortix_dirent) ) { return -1; }
size_t namelen = String::Length(name); size_t namelen = strlen(name);
size_t needed = sizeof(sortix_dirent) + namelen + 1; size_t needed = sizeof(sortix_dirent) + namelen + 1;
if ( available < needed ) if ( available < needed )
@ -366,7 +366,7 @@ namespace Sortix
if ( String::Compare(path, "/video") == 0 || if ( String::Compare(path, "/video") == 0 ||
String::StartsWith(path, "/video/") ) String::StartsWith(path, "/video/") )
{ {
return DeviceFS::videofs->Open(path + String::Length("/video"), flags, mode); return DeviceFS::videofs->Open(path + strlen("/video"), flags, mode);
} }
Device* dev = DeviceFS::LookUp(path + 1); Device* dev = DeviceFS::LookUp(path + 1);

View File

@ -188,7 +188,7 @@ namespace Sortix
} }
const char* name = InitRD::GetFilename(dir, position); const char* name = InitRD::GetFilename(dir, position);
size_t namelen = String::Length(name); size_t namelen = strlen(name);
size_t needed = sizeof(sortix_dirent) + namelen + 1; size_t needed = sizeof(sortix_dirent) + namelen + 1;
if ( available < needed ) if ( available < needed )

View File

@ -217,7 +217,7 @@ namespace Sortix
const char* name = fs->GetFilename(position); const char* name = fs->GetFilename(position);
if ( !name ) { return -1; } if ( !name ) { return -1; }
size_t namelen = String::Length(name); size_t namelen = strlen(name);
size_t needed = sizeof(sortix_dirent) + namelen + 1; size_t needed = sizeof(sortix_dirent) + namelen + 1;
if ( available < needed ) if ( available < needed )
@ -260,7 +260,7 @@ namespace Sortix
if ( *path++ != '/' ) { errno = ENOENT; return NULL; } if ( *path++ != '/' ) { errno = ENOENT; return NULL; }
size_t pathlen = String::Length(path); size_t pathlen = strlen(path);
for ( size_t i = 0; i < pathlen; i++ ) for ( size_t i = 0; i < pathlen; i++ )
{ {
if ( path[i] == '/' ) { errno = ENOENT; return NULL; } if ( path[i] == '/' ) { errno = ENOENT; return NULL; }

View File

@ -35,7 +35,7 @@ namespace Sortix {
DevStringBuffer::DevStringBuffer(char* str) DevStringBuffer::DevStringBuffer(char* str)
{ {
this->str = str; this->str = str;
strlength = String::Length(str); strlength = strlen(str);
off = 0; off = 0;
} }

View File

@ -166,7 +166,7 @@ Device* MakeModes(int flags, mode_t /*mode*/)
size_t combinedlen = 0; size_t combinedlen = 0;
for ( size_t i = 0; i < nummodes; i++ ) for ( size_t i = 0; i < nummodes; i++ )
{ {
combinedlen += String::Length(modes[i]) + 1 /*newline*/; combinedlen += strlen(modes[i]) + 1 /*newline*/;
} }
size_t sofar = 0; size_t sofar = 0;
char* modesstr = new char[combinedlen + 1]; char* modesstr = new char[combinedlen + 1];
@ -174,7 +174,7 @@ Device* MakeModes(int flags, mode_t /*mode*/)
for ( size_t i = 0; i < nummodes; i++ ) for ( size_t i = 0; i < nummodes; i++ )
{ {
String::Copy(modesstr + sofar, modes[i]); String::Copy(modesstr + sofar, modes[i]);
sofar += String::Length(modes[i]); sofar += strlen(modes[i]);
modesstr[sofar++] = '\n'; modesstr[sofar++] = '\n';
} }
modesstr[sofar] = 0; modesstr[sofar] = 0;
@ -269,7 +269,7 @@ int DevVideoFSDir::Read(sortix_dirent* dirent, size_t available)
} }
const char* name = nodes[position].name; const char* name = nodes[position].name;
size_t namelen = String::Length(name); size_t namelen = strlen(name);
size_t needed = sizeof(sortix_dirent) + namelen + 1; size_t needed = sizeof(sortix_dirent) + namelen + 1;
if ( available < needed ) if ( available < needed )

View File

@ -50,7 +50,7 @@ ssize_t SysKernelInfo(const char* req, char* resp, size_t resplen)
{ {
const char* str = KernelInfo(req); const char* str = KernelInfo(req);
if ( !str ) { errno = EINVAL; return -1; } if ( !str ) { errno = EINVAL; return -1; }
size_t stringlen = String::Length(str); size_t stringlen = strlen(str);
if ( resplen < stringlen + 1 ) if ( resplen < stringlen + 1 )
{ {
errno = ERANGE; errno = ERANGE;

View File

@ -72,7 +72,7 @@ namespace Sortix
bool MatchesMountPath(const char* path, const char* mount) bool MatchesMountPath(const char* path, const char* mount)
{ {
size_t mountlen = String::Length(mount); size_t mountlen = strlen(mount);
if ( !String::StartsWith(path, mount) ) { return false; } if ( !String::StartsWith(path, mount) ) { return false; }
int c = path[mountlen]; int c = path[mountlen];
return c == '/' || c == '\0'; return c == '/' || c == '\0';
@ -88,7 +88,7 @@ namespace Sortix
if ( MatchesMountPath(path, tmp->path) ) if ( MatchesMountPath(path, tmp->path) )
{ {
result = tmp->fs; result = tmp->fs;
*pathoffset = String::Length(tmp->path); *pathoffset = strlen(tmp->path);
} }
} }

View File

@ -529,7 +529,7 @@ namespace Sortix
size_t argvsize = 0; size_t argvsize = 0;
for ( int i = 0; i < argc; i++ ) for ( int i = 0; i < argc; i++ )
{ {
size_t len = String::Length(argv[i]) + 1; size_t len = strlen(argv[i]) + 1;
argvsize += len; argvsize += len;
char* dest = ((char*) argvpos) - argvsize; char* dest = ((char*) argvpos) - argvsize;
stackargv[i] = dest; stackargv[i] = dest;
@ -547,7 +547,7 @@ namespace Sortix
size_t envpsize = 0; size_t envpsize = 0;
for ( int i = 0; i < envc; i++ ) for ( int i = 0; i < envc; i++ )
{ {
size_t len = String::Length(envp[i]) + 1; size_t len = strlen(envp[i]) + 1;
envpsize += len; envpsize += len;
char* dest = ((char*) envppos) - envpsize; char* dest = ((char*) envppos) - envpsize;
stackenvp[i] = dest; stackenvp[i] = dest;

View File

@ -41,7 +41,7 @@ namespace Sortix
{ {
// Set the cursor to (0,0) and clear the screen. // Set the cursor to (0,0) and clear the screen.
const char InitMessage[] = "\e[37m\e[40m\e[2J\e[H"; const char InitMessage[] = "\e[37m\e[40m\e[2J\e[H";
UART::Write(InitMessage, String::Length(InitMessage)); UART::Write(InitMessage, strlen(InitMessage));
} }
bool isEsc; bool isEsc;
@ -135,7 +135,7 @@ namespace Sortix
if ( !cursordisabled ) if ( !cursordisabled )
{ {
const char* msg = "\e[l"; const char* msg = "\e[l";
UART::Write(msg, String::Length(msg)); UART::Write(msg, strlen(msg));
cursordisabled = true; cursordisabled = true;
} }
UART::RenderVGA((const uint16_t*) 0xB8000); UART::RenderVGA((const uint16_t*) 0xB8000);
@ -150,7 +150,7 @@ namespace Sortix
if ( cursordisabled ) if ( cursordisabled )
{ {
const char* msg = "\e[h"; const char* msg = "\e[h";
UART::Write(msg, String::Length(msg)); UART::Write(msg, strlen(msg));
cursordisabled = false; cursordisabled = false;
} }
UART::Write(string, stringlen); UART::Write(string, stringlen);