[Assorted-commits] SF.net SVN: assorted:[1235] cpp-commons/trunk/src/commons
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-02-26 03:16:07
|
Revision: 1235 http://assorted.svn.sourceforge.net/assorted/?rev=1235&view=rev Author: yangzhang Date: 2009-02-26 03:15:58 +0000 (Thu, 26 Feb 2009) Log Message: ----------- - removed checkpass wrappers around new operator - changed array::reset() to take size Modified Paths: -------------- cpp-commons/trunk/src/commons/array.h cpp-commons/trunk/src/commons/files.h cpp-commons/trunk/src/commons/st/st.h Modified: cpp-commons/trunk/src/commons/array.h =================================================================== --- cpp-commons/trunk/src/commons/array.h 2009-02-25 21:13:24 UTC (rev 1234) +++ cpp-commons/trunk/src/commons/array.h 2009-02-26 03:15:58 UTC (rev 1235) @@ -46,13 +46,13 @@ EXPAND(unique_ptr<T[]>) friend void swap<>(array<T> &a, array<T> &b); public: - explicit array(size_t n) : p_(checkpass(new T[n])), n_(n) {} + explicit array(size_t n) : p_(new T[n]), n_(n) {} size_t size() const { return n_; } T *get() const { return p_.get(); } T *release() { return p_.release(); } T *end() const { return this->get() + n_; } T operator[](size_t i) const { return p_[i]; } - void reset(T *p) { p_.reset(p); } + void reset(T *p, size_t n) { p_.reset(p); n_ = n; } private: unique_ptr<T[]> p_; size_t n_; Modified: cpp-commons/trunk/src/commons/files.h =================================================================== --- cpp-commons/trunk/src/commons/files.h 2009-02-25 21:13:24 UTC (rev 1234) +++ cpp-commons/trunk/src/commons/files.h 2009-02-26 03:15:58 UTC (rev 1235) @@ -63,7 +63,7 @@ // TODO Why don't we need (static) cast here? Isn't this a lossy cast? len = sb.st_size; - char *buf = checkpass(new char[len + 1]); + char *buf = new char[len + 1]; checkeqnneg(pread(fd, buf, len, 0), static_cast<ssize_t>(len)); // TODO Use threads to pull data to the correct initial locations? Modified: cpp-commons/trunk/src/commons/st/st.h =================================================================== --- cpp-commons/trunk/src/commons/st/st.h 2009-02-25 21:13:24 UTC (rev 1234) +++ cpp-commons/trunk/src/commons/st/st.h 2009-02-26 03:15:58 UTC (rev 1235) @@ -452,7 +452,7 @@ // Handle large arrays specially. if (req > buf_.size()) { - managed_array<char> p(checkpass(new char[req]), true); + managed_array<char> p(new char[req], true); memcpy(p.get(), start_, unread()); checkeqnneg(st_read_fully(fd_, p + unread(), req - unread(), to), static_cast<ssize_t>(req - unread())); start_ = end_ = buf_.get(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |