Skip to content

Commit

Permalink
update base
Browse files Browse the repository at this point in the history
  • Loading branch information
hxxft committed May 16, 2018
1 parent a2ba324 commit d228d9f
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 24 deletions.
3 changes: 2 additions & 1 deletion Core/base/debug/backtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace {
void** current;
void** end;
};

#if OS_ANDROID
static _Unwind_Reason_Code unwindCallback(struct _Unwind_Context* context, void* arg)
{
BacktraceState* state = static_cast<BacktraceState*>(arg);
Expand All @@ -35,6 +35,7 @@ namespace {
}
return _URC_NO_REASON;
}
#endif

}
namespace base {
Expand Down
6 changes: 3 additions & 3 deletions Core/base/debug/memory_debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "base/debug/memory_tracker.h"

#if DEBUG_MEMORY
void * operator new (size_t size, const char* file, int line) {
void * operator new (size_t size, const char* file, int line) noexcept {
if(0 == size){
return NULL;
}
Expand All @@ -13,7 +13,7 @@ void * operator new (size_t size, const char* file, int line) {
return p;
}

void * operator new [](size_t size, const char* file, int line) {
void * operator new [](size_t size, const char* file, int line) noexcept {
void *p = ::operator new(size);
base::MemoryTracker::Instance()->AddMemInfo(reinterpret_cast<intptr_t>(p), file, line);
return p;
Expand All @@ -31,4 +31,4 @@ void operator delete[](void * pointer, const char* file, int line) noexcept{
::operator delete(pointer);
}

#endif
#endif
6 changes: 3 additions & 3 deletions Core/base/debug/memory_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#if DEBUG_MEMORY

void * operator new (size_t size, const char* file, int line) ;
void * operator new [](size_t size, const char* file, int line) ;
void * operator new (size_t size, const char* file, int line) noexcept;
void * operator new [](size_t size, const char* file, int line) noexcept;
void operator delete (void * pointer, const char* file, int line) noexcept;
void operator delete[](void * pointer, const char* file, int line) noexcept;

Expand Down Expand Up @@ -37,4 +37,4 @@ void operator delete[](void * pointer, const char* file, int line) noexcept;
delete[] ptr; \

#endif
#endif
#endif
4 changes: 2 additions & 2 deletions Core/base/io_buffer.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "base/io_buffer.h"

namespace base {
IOBuffer::IOBuffer(size_t size) {
IOBuffer::IOBuffer(int size) {
data_ = new char[size];
}

Expand All @@ -12,7 +12,7 @@ IOBuffer::~IOBuffer() {
data_ = nullptr;
}

IOBufferWithSize::IOBufferWithSize(size_t size) : IOBuffer(size), size_(size) {}
IOBufferWithSize::IOBufferWithSize(int size) : IOBuffer(size), size_(size) {}

GrowableIOBuffer::GrowableIOBuffer() : IOBuffer(), capacity_(0), offset_(0) {}

Expand Down
14 changes: 7 additions & 7 deletions Core/base/io_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace base {
class IOBuffer : public base::RefCountPtr<IOBuffer> {
public:
IOBuffer(size_t size);
IOBuffer(int size);
IOBuffer() : data_(NULL) {}
virtual ~IOBuffer();
char* data() { return data_; }
Expand All @@ -19,13 +19,13 @@ class IOBuffer : public base::RefCountPtr<IOBuffer> {

class IOBufferWithSize : public IOBuffer {
public:
explicit IOBufferWithSize(size_t size);
explicit IOBufferWithSize(int size);
virtual ~IOBufferWithSize() {}

size_t size() const { return size_; }
int size() const { return size_; }

protected:
size_t size_;
int size_;
};

class StringIOBuffer : public IOBuffer {
Expand All @@ -45,7 +45,7 @@ class StringIOBuffer : public IOBuffer {

class DrainableIOBuffer : public IOBuffer {
public:
DrainableIOBuffer(IOBuffer* base, size_t size)
DrainableIOBuffer(IOBuffer* base, int size)
: IOBuffer(base->data()), base_(base), size_(size), used_(0) {}

virtual ~DrainableIOBuffer() { data_ = nullptr; }
Expand All @@ -62,8 +62,8 @@ class DrainableIOBuffer : public IOBuffer {
private:
base::ScopedRefPtr<IOBuffer> base_;

size_t size_;
size_t used_;
int size_;
int used_;
};

class GrowableIOBuffer : public IOBuffer {
Expand Down
2 changes: 1 addition & 1 deletion Core/base/poller/poller.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Poller {

virtual void RemoveFileDescriptor(int fd) = 0;

virtual void Poll(int timeout) = 0;
virtual void Poll(int64_t timeout) = 0;

protected:
ScopedPtrMap<int, FileDescriptor> file_descriptors_;
Expand Down
4 changes: 2 additions & 2 deletions Core/base/poller/select_poller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SelectPoller::~SelectPoller() {}

void SelectPoller::WatchFileDescriptor(FileDescriptor* descriptor) {
int fd = descriptor->fd();
int event = descriptor->event();

auto iter = file_descriptors_.find(fd);
if (iter != file_descriptors_.end()) {
return;
Expand Down Expand Up @@ -41,7 +41,7 @@ void SelectPoller::RemoveFileDescriptor(int fd) {
fd_set_.erase(fd);
}

void SelectPoller::Poll(int timeout) {
void SelectPoller::Poll(int64_t timeout) {
struct timeval tv = {0, 0};
struct timeval* ptv = &tv;

Expand Down
2 changes: 1 addition & 1 deletion Core/base/poller/select_poller.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SelectPoller : public Poller {

virtual void RemoveFileDescriptor(int fd);

virtual void Poll(int timeout);
virtual void Poll(int64_t timeout);

private:
void ResetFileDescriptor();
Expand Down
2 changes: 1 addition & 1 deletion Core/base/rand_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void RandomBuffer(char* buffer, size_t length) {
if (!seeded) {
seeded = true;
// could fread from /dev/random
srand(time(NULL));
srand((unsigned)time(NULL));
}
size_t i;
for (i = 0; i < length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions Core/base/scoped_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ScopedVector {

bool empty() { return vector_.empty(); }

T* operator[] (int index) {
T* operator[] (size_t index) {
return vector_[index];
}

Expand All @@ -43,7 +43,7 @@ class ScopedVector {
vector_.pop_back();
}

T* at(int n) {
T* at(size_t n) {
return vector_.at(n);
}

Expand Down
5 changes: 4 additions & 1 deletion Core/base/threading/message_pump_io_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ void MessagePumpIOPosix::Run(Delegate* delegate) {

void MessagePumpIOPosix::OnFileCanRead(int fd) {
char buf;
int nread = read(fd, &buf, 1);
size_t nread = read(fd, &buf, 1);
if(nread != 1) {
DLOG(ERROR) <<"MessagePumpIOPosix Read Error";
}
}

void MessagePumpIOPosix::OnFileCanWrite(int fd) {}
Expand Down

0 comments on commit d228d9f

Please sign in to comment.