Namespace- and gcc3-related fixes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3405 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
haydentech
2003-06-03 18:29:29 +00:00
parent df1b8782c7
commit a0a3f269a4
10 changed files with 56 additions and 57 deletions
+3 -3
View File
@@ -114,7 +114,7 @@ status_t entry_ref::set_name(const char *name)
if (name == NULL) { if (name == NULL) {
this->name = NULL; this->name = NULL;
} else { } else {
this->name = new(nothrow) char[strlen(name)+1]; this->name = new(std::nothrow) char[strlen(name)+1];
if (this->name == NULL) if (this->name == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
strcpy(this->name, name); strcpy(this->name, name);
@@ -764,7 +764,7 @@ BEntry::Rename(const char *path, bool clobber)
*/ */
status_t status_t
BEntry::MoveTo(BDirectory *dir, const char *path = NULL, bool clobber) BEntry::MoveTo(BDirectory *dir, const char *path, bool clobber)
{ {
if (fCStatus != B_OK) if (fCStatus != B_OK)
return B_NO_INIT; return B_NO_INIT;
@@ -1047,7 +1047,7 @@ BEntry::set_name(const char *name)
delete [] fName; delete [] fName;
} }
fName = new(nothrow) char[strlen(name)+1]; fName = new(std::nothrow) char[strlen(name)+1];
if (fName == NULL) if (fName == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
+1 -1
View File
@@ -99,7 +99,7 @@ BMimeType::SetTo(const char *mimeType)
fCStatus = B_BAD_VALUE; fCStatus = B_BAD_VALUE;
} else { } else {
Unset(); Unset();
fType = new(nothrow) char[strlen(mimeType)+1]; fType = new(std::nothrow) char[strlen(mimeType)+1];
if (fType) { if (fType) {
strcpy(fType, mimeType); strcpy(fType, mimeType);
fCStatus = B_OK; fCStatus = B_OK;
+1 -1
View File
@@ -600,7 +600,7 @@ BPath::set_path(const char *path)
const char *oldPath = fName; const char *oldPath = fName;
// set the new path // set the new path
if (path) { if (path) {
fName = new(nothrow) char[strlen(path) + 1]; fName = new(std::nothrow) char[strlen(path) + 1];
if (fName) if (fName)
strcpy(fName, path); strcpy(fName, path);
else else
+15 -15
View File
@@ -9,7 +9,7 @@
#include <Query.h> #include <Query.h>
#include <fs_query.h> #include <fs_query.h>
#include <new.h> #include <new>
#include <parsedate.h> #include <parsedate.h>
#include <time.h> #include <time.h>
@@ -95,7 +95,7 @@ BQuery::Clear()
status_t status_t
BQuery::PushAttr(const char *attrName) BQuery::PushAttr(const char *attrName)
{ {
return _PushNode(new(nothrow) AttributeNode(attrName), true); return _PushNode(new(std::nothrow) AttributeNode(attrName), true);
} }
// PushOp // PushOp
@@ -129,13 +129,13 @@ BQuery::PushOp(query_op op)
case B_ENDS_WITH: case B_ENDS_WITH:
case B_AND: case B_AND:
case B_OR: case B_OR:
error = _PushNode(new(nothrow) BinaryOpNode(op), true); error = _PushNode(new(std::nothrow) BinaryOpNode(op), true);
break; break;
case B_NOT: case B_NOT:
error = _PushNode(new(nothrow) UnaryOpNode(op), true); error = _PushNode(new(std::nothrow) UnaryOpNode(op), true);
break; break;
default: default:
error = _PushNode(new(nothrow) SpecialOpNode(op), true); error = _PushNode(new(std::nothrow) SpecialOpNode(op), true);
break; break;
} }
return error; return error;
@@ -159,7 +159,7 @@ BQuery::PushOp(query_op op)
status_t status_t
BQuery::PushUInt32(uint32 value) BQuery::PushUInt32(uint32 value)
{ {
return _PushNode(new(nothrow) UInt32ValueNode(value), true); return _PushNode(new(std::nothrow) UInt32ValueNode(value), true);
} }
// PushInt32 // PushInt32
@@ -180,7 +180,7 @@ BQuery::PushUInt32(uint32 value)
status_t status_t
BQuery::PushInt32(int32 value) BQuery::PushInt32(int32 value)
{ {
return _PushNode(new(nothrow) Int32ValueNode(value), true); return _PushNode(new(std::nothrow) Int32ValueNode(value), true);
} }
// PushUInt64 // PushUInt64
@@ -201,7 +201,7 @@ BQuery::PushInt32(int32 value)
status_t status_t
BQuery::PushUInt64(uint64 value) BQuery::PushUInt64(uint64 value)
{ {
return _PushNode(new(nothrow) UInt64ValueNode(value), true); return _PushNode(new(std::nothrow) UInt64ValueNode(value), true);
} }
// PushInt64 // PushInt64
@@ -222,7 +222,7 @@ BQuery::PushUInt64(uint64 value)
status_t status_t
BQuery::PushInt64(int64 value) BQuery::PushInt64(int64 value)
{ {
return _PushNode(new(nothrow) Int64ValueNode(value), true); return _PushNode(new(std::nothrow) Int64ValueNode(value), true);
} }
// PushFloat // PushFloat
@@ -243,7 +243,7 @@ BQuery::PushInt64(int64 value)
status_t status_t
BQuery::PushFloat(float value) BQuery::PushFloat(float value)
{ {
return _PushNode(new(nothrow) FloatValueNode(value), true); return _PushNode(new(std::nothrow) FloatValueNode(value), true);
} }
// PushDouble // PushDouble
@@ -264,7 +264,7 @@ BQuery::PushFloat(float value)
status_t status_t
BQuery::PushDouble(double value) BQuery::PushDouble(double value)
{ {
return _PushNode(new(nothrow) DoubleValueNode(value), true); return _PushNode(new(std::nothrow) DoubleValueNode(value), true);
} }
// PushString // PushString
@@ -287,7 +287,7 @@ BQuery::PushDouble(double value)
status_t status_t
BQuery::PushString(const char *value, bool caseInsensitive) BQuery::PushString(const char *value, bool caseInsensitive)
{ {
return _PushNode(new(nothrow) StringNode(value, caseInsensitive), true); return _PushNode(new(std::nothrow) StringNode(value, caseInsensitive), true);
} }
// PushDate // PushDate
@@ -319,7 +319,7 @@ BQuery::PushDate(const char *date)
} }
} }
if (error == B_OK) if (error == B_OK)
error = _PushNode(new(nothrow) DateNode(date), true); error = _PushNode(new(std::nothrow) DateNode(date), true);
return error; return error;
} }
@@ -677,7 +677,7 @@ BQuery::_PushNode(QueryNode *node, bool deleteOnError)
error = B_NOT_ALLOWED; error = B_NOT_ALLOWED;
// allocate the stack, if necessary // allocate the stack, if necessary
if (error == B_OK && !fStack) { if (error == B_OK && !fStack) {
fStack = new(nothrow) QueryStack; fStack = new(std::nothrow) QueryStack;
if (!fStack) if (!fStack)
error = B_NO_MEMORY; error = B_NO_MEMORY;
} }
@@ -705,7 +705,7 @@ BQuery::_SetPredicate(const char *expression)
fPredicate = NULL; fPredicate = NULL;
// set the new one // set the new one
if (expression) { if (expression) {
fPredicate = new(nothrow) char[strlen(expression) + 1]; fPredicate = new(std::nothrow) char[strlen(expression) + 1];
if (fPredicate) if (fPredicate)
strcpy(fPredicate, expression); strcpy(fPredicate, expression);
else else
+4 -4
View File
@@ -822,7 +822,7 @@ ResourceFile::_ReadIndexEntry(resource_parse_info &parseInfo, int32 index,
} }
// add the entry // add the entry
if (result) { if (result) {
ResourceItem *item = new(nothrow) ResourceItem; ResourceItem *item = new(std::nothrow) ResourceItem;
if (!item) if (!item)
throw Exception(B_NO_MEMORY); throw Exception(B_NO_MEMORY);
item->SetLocation(offset, size); item->SetLocation(offset, size);
@@ -841,7 +841,7 @@ ResourceFile::_ReadInfoTable(resource_parse_info &parseInfo)
int32 &resourceCount = parseInfo.resource_count; int32 &resourceCount = parseInfo.resource_count;
// read the info table // read the info table
// alloc memory for the table // alloc memory for the table
char *tableData = new(nothrow) char[parseInfo.info_table_size]; char *tableData = new(std::nothrow) char[parseInfo.info_table_size];
if (!tableData) if (!tableData)
throw Exception(B_NO_MEMORY); throw Exception(B_NO_MEMORY);
int32 dataSize = parseInfo.info_table_size; int32 dataSize = parseInfo.info_table_size;
@@ -849,7 +849,7 @@ ResourceFile::_ReadInfoTable(resource_parse_info &parseInfo)
read_exactly(fFile, parseInfo.info_table_offset, tableData, dataSize, read_exactly(fFile, parseInfo.info_table_offset, tableData, dataSize,
"Failed to read resource info table."); "Failed to read resource info table.");
// //
bool *readIndices = new(nothrow) bool[resourceCount + 1]; bool *readIndices = new(std::nothrow) bool[resourceCount + 1];
// + 1 => always > 0 // + 1 => always > 0
if (!readIndices) if (!readIndices)
throw Exception(B_NO_MEMORY); throw Exception(B_NO_MEMORY);
@@ -1074,7 +1074,7 @@ ResourceFile::_WriteResources(ResourcesContainer &container)
// write... // write...
// set the file size // set the file size
fFile.SetSize(size); fFile.SetSize(size);
buffer = new(nothrow) char[bufferSize]; buffer = new(std::nothrow) char[bufferSize];
if (!buffer) if (!buffer)
throw Exception(B_NO_MEMORY); throw Exception(B_NO_MEMORY);
void *data = buffer; void *data = buffer;
+6 -6
View File
@@ -39,7 +39,7 @@ BResources::BResources()
fResourceFile(NULL), fResourceFile(NULL),
fReadOnly(false) fReadOnly(false)
{ {
fContainer = new(nothrow) ResourcesContainer; fContainer = new(std::nothrow) ResourcesContainer;
} }
// constructor // constructor
@@ -61,7 +61,7 @@ BResources::BResources(const BFile *file, bool clobber)
fResourceFile(NULL), fResourceFile(NULL),
fReadOnly(false) fReadOnly(false)
{ {
fContainer = new(nothrow) ResourcesContainer; fContainer = new(std::nothrow) ResourcesContainer;
SetTo(file, clobber); SetTo(file, clobber);
} }
@@ -109,7 +109,7 @@ BResources::SetTo(const BFile *file, bool clobber)
} }
if (error == B_OK) { if (error == B_OK) {
fReadOnly = !fFile.IsWritable(); fReadOnly = !fFile.IsWritable();
fResourceFile = new(nothrow) ResourceFile; fResourceFile = new(std::nothrow) ResourceFile;
if (fResourceFile) if (fResourceFile)
error = fResourceFile->SetTo(&fFile, clobber); error = fResourceFile->SetTo(&fFile, clobber);
else else
@@ -148,7 +148,7 @@ BResources::Unset()
if (fContainer) if (fContainer)
fContainer->MakeEmpty(); fContainer->MakeEmpty();
else else
fContainer = new(nothrow) ResourcesContainer; fContainer = new(std::nothrow) ResourcesContainer;
fReadOnly = false; fReadOnly = false;
} }
@@ -383,7 +383,7 @@ BResources::WriteTo(BFile *file)
// set the new file, but keep the old container // set the new file, but keep the old container
if (error == B_OK) { if (error == B_OK) {
ResourcesContainer *container = fContainer; ResourcesContainer *container = fContainer;
fContainer = new(nothrow) ResourcesContainer; fContainer = new(std::nothrow) ResourcesContainer;
if (fContainer) { if (fContainer) {
error = SetTo(file, false); error = SetTo(file, false);
delete fContainer; delete fContainer;
@@ -425,7 +425,7 @@ BResources::AddResource(type_code type, int32 id, const void *data,
if (error == B_OK) if (error == B_OK)
error = (fReadOnly ? B_NOT_ALLOWED : B_OK); error = (fReadOnly ? B_NOT_ALLOWED : B_OK);
if (error == B_OK) { if (error == B_OK) {
ResourceItem *item = new(nothrow) ResourceItem; ResourceItem *item = new(std::nothrow) ResourceItem;
if (!item) if (!item)
error = B_NO_MEMORY; error = B_NO_MEMORY;
if (error == B_OK) { if (error == B_OK) {
+6 -7
View File
@@ -12,7 +12,6 @@
#include <SymLink.h> #include <SymLink.h>
#include <Directory.h> #include <Directory.h>
#include <Entry.h> #include <Entry.h>
#include <Entry.h>
#include <Path.h> #include <Path.h>
#include "kernel_interface.h" #include "kernel_interface.h"
#include "storage_support.h" #include "storage_support.h"
@@ -26,7 +25,7 @@ namespace OpenBeOS {
BSymLink::BSymLink() BSymLink::BSymLink()
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(nothrow) BEntry) , fSecretEntry(new(std::nothrow) BEntry)
{ {
} }
@@ -37,7 +36,7 @@ BSymLink::BSymLink()
BSymLink::BSymLink(const BSymLink &link) BSymLink::BSymLink(const BSymLink &link)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(nothrow) BEntry) , fSecretEntry(new(std::nothrow) BEntry)
{ {
*this = link; *this = link;
} }
@@ -50,7 +49,7 @@ BSymLink::BSymLink(const BSymLink &link)
BSymLink::BSymLink(const entry_ref *ref) BSymLink::BSymLink(const entry_ref *ref)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(nothrow) BEntry) , fSecretEntry(new(std::nothrow) BEntry)
{ {
SetTo(ref); SetTo(ref);
} }
@@ -63,7 +62,7 @@ BSymLink::BSymLink(const entry_ref *ref)
BSymLink::BSymLink(const BEntry *entry) BSymLink::BSymLink(const BEntry *entry)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(nothrow) BEntry) , fSecretEntry(new(std::nothrow) BEntry)
{ {
SetTo(entry); SetTo(entry);
} }
@@ -76,7 +75,7 @@ BSymLink::BSymLink(const BEntry *entry)
BSymLink::BSymLink(const char *path) BSymLink::BSymLink(const char *path)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(nothrow) BEntry) , fSecretEntry(new(std::nothrow) BEntry)
{ {
SetTo(path); SetTo(path);
} }
@@ -91,7 +90,7 @@ BSymLink::BSymLink(const char *path)
BSymLink::BSymLink(const BDirectory *dir, const char *path) BSymLink::BSymLink(const BDirectory *dir, const char *path)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(nothrow) BEntry) , fSecretEntry(new(std::nothrow) BEntry)
{ {
SetTo(dir, path); SetTo(dir, path);
} }
+1 -1
View File
@@ -172,7 +172,7 @@ BVolumeRoster::StartWatching(BMessenger messenger)
status_t error = (messenger.IsValid() ? B_OK : B_ERROR); status_t error = (messenger.IsValid() ? B_OK : B_ERROR);
// clone messenger // clone messenger
if (error == B_OK) { if (error == B_OK) {
fTarget = new(nothrow) BMessenger(messenger); fTarget = new(std::nothrow) BMessenger(messenger);
if (!fTarget) if (!fTarget)
error = B_NO_MEMORY; error = B_NO_MEMORY;
} }
+16 -16
View File
@@ -14,7 +14,7 @@
#include "LibBeAdapter.h" #include "LibBeAdapter.h"
#include <algobase.h> #include <algorithm>
#include <fsproto.h> #include <fsproto.h>
#include <errno.h> // errno #include <errno.h> // errno
#include <new> #include <new>
@@ -253,32 +253,32 @@ BPrivate::Storage::sync( FileDescriptor file )
//! /todo Get rid of DumpLock() at some point (it's only for debugging) //! /todo Get rid of DumpLock() at some point (it's only for debugging)
void DumpLock(BPrivate::Storage::FileLock &lock) void DumpLock(BPrivate::Storage::FileLock &lock)
{ {
cout << endl; std::cout << std::endl;
cout << "type == "; std::cout << "type == ";
switch (lock.l_type) { switch (lock.l_type) {
case F_RDLCK: case F_RDLCK:
cout << "F_RDLCK"; std::cout << "F_RDLCK";
break; break;
case F_WRLCK: case F_WRLCK:
cout << "F_WRLCK"; std::cout << "F_WRLCK";
break; break;
case F_UNLCK: case F_UNLCK:
cout << "F_UNLCK"; std::cout << "F_UNLCK";
break; break;
default: default:
cout << lock.l_type; std::cout << lock.l_type;
break; break;
} }
cout << endl; std::cout << std::endl;
cout << "whence == " << lock.l_whence << endl; std::cout << "whence == " << lock.l_whence << std::endl;
cout << "start == " << lock.l_start << endl; std::cout << "start == " << lock.l_start << std::endl;
cout << "len == " << lock.l_len << endl; std::cout << "len == " << lock.l_len << std::endl;
cout << "pid == " << lock.l_pid << endl; std::cout << "pid == " << lock.l_pid << std::endl;
cout << endl; std::cout << std::endl;
} }
// As best I can tell, fcntl(fd, F_SETLK, lock) and fcntl(fd, F_GETLK, lock) // As best I can tell, fcntl(fd, F_SETLK, lock) and fcntl(fd, F_GETLK, lock)
@@ -544,7 +544,7 @@ BPrivate::Storage::rename_attr(FileDescriptor file, const char *oldName,
char *data = NULL; char *data = NULL;
if (error == B_OK) { if (error == B_OK) {
// alloc at least one byte // alloc at least one byte
data = new(nothrow) char[max(info.size, 1LL)]; data = new(std::nothrow) char[max(info.size, 1LL)];
if (data == NULL) if (data == NULL)
error = B_NO_MEMORY; error = B_NO_MEMORY;
} }
@@ -1072,7 +1072,7 @@ BPrivate::Storage::get_canonical_path(const char *path, char *&result)
{ {
status_t error = (path ? B_OK : B_BAD_VALUE); status_t error = (path ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
result = new(nothrow) char[B_PATH_NAME_LENGTH]; result = new(std::nothrow) char[B_PATH_NAME_LENGTH];
if (!result) if (!result)
error = B_NO_MEMORY; error = B_NO_MEMORY;
if (error == B_OK) { if (error == B_OK) {
@@ -1117,7 +1117,7 @@ BPrivate::Storage::get_canonical_dir_path(const char *path, char *&result)
{ {
status_t error = (path ? B_OK : B_BAD_VALUE); status_t error = (path ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
result = new(nothrow) char[B_PATH_NAME_LENGTH]; result = new(std::nothrow) char[B_PATH_NAME_LENGTH];
if (!result) if (!result)
error = B_NO_MEMORY; error = B_NO_MEMORY;
if (error == B_OK) { if (error == B_OK) {
+3 -3
View File
@@ -171,7 +171,7 @@ split_path(const char *fullPath, char **path, char **leaf)
memcpy(*leaf, fullPath + leafStart, len); memcpy(*leaf, fullPath + leafStart, len);
(*leaf)[len] = 0; (*leaf)[len] = 0;
} }
} catch (bad_alloc exception) { } catch (std::bad_alloc exception) {
if (path) if (path)
delete[] *path; delete[] *path;
if (leaf) if (leaf)
@@ -232,7 +232,7 @@ parse_first_path_component(const char *path, char *&component,
int32 length; int32 length;
status_t error = parse_first_path_component(path, length, nextComponent); status_t error = parse_first_path_component(path, length, nextComponent);
if (error == B_OK) { if (error == B_OK) {
component = new(nothrow) char[length + 1]; component = new(std::nothrow) char[length + 1];
if (component) { if (component) {
strncpy(component, path, length); strncpy(component, path, length);
component[length] = '\0'; component[length] = '\0';
@@ -376,7 +376,7 @@ void escape_path(const char *str, char *result)
void escape_path(char *str) void escape_path(char *str)
{ {
if (str) { if (str) {
char *copy = new(nothrow) char[strlen(str)+1]; char *copy = new(std::nothrow) char[strlen(str)+1];
if (copy) { if (copy) {
strcpy(copy, str); strcpy(copy, str);
escape_path(copy, str); escape_path(copy, str);