Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: src/utils.cc

Issue 1940: Replaced calls to functions that msvc consider deprecated. Used... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils.h ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.cc
===================================================================
--- src/utils.cc (revision 280)
+++ src/utils.cc (working copy)
@@ -155,7 +155,7 @@
int* size,
int extra_space,
bool verbose) {
- FILE* file = fopen(filename, "rb");
+ FILE* file = OS::FOpen(filename, "rb");
if (file == NULL || fseek(file, 0, SEEK_END) != 0) {
if (verbose) {
OS::PrintError("Cannot read from file %s.\n", filename);
@@ -220,7 +220,7 @@
const char* str,
int size,
bool verbose) {
- FILE* f = fopen(filename, "wb");
+ FILE* f = OS::FOpen(filename, "wb");
if (f == NULL) {
if (verbose) {
OS::PrintError("Cannot open file %s for reading.\n", filename);
@@ -234,8 +234,7 @@
StringBuilder::StringBuilder(int size) {
- buffer_ = NewArray<char>(size);
- size_ = size;
+ buffer_ = Vector<char>::New(size);
position_ = 0;
}
@@ -246,7 +245,7 @@
void StringBuilder::AddSubstring(const char* s, int n) {
- ASSERT(!is_finalized() && position_ + n < size_);
+ ASSERT(!is_finalized() && position_ + n < buffer_.length());
ASSERT(static_cast<size_t>(n) <= strlen(s));
memcpy(&buffer_[position_], s, n * kCharSize);
position_ += n;
@@ -254,14 +253,13 @@
void StringBuilder::AddFormatted(const char* format, ...) {
- ASSERT(!is_finalized() && position_ < size_);
+ ASSERT(!is_finalized() && position_ < buffer_.length());
va_list args;
va_start(args, format);
- int remaining = size_ - position_;
- int n = OS::VSNPrintF(&buffer_[position_], remaining, format, args);
+ int n = OS::VSNPrintF(buffer_ + position_, format, args);
va_end(args);
- if (n < 0 || n >= remaining) {
- position_ = size_;
+ if (n < 0 || n >= (buffer_.length() - position_)) {
+ position_ = buffer_.length();
} else {
position_ += n;
}
@@ -276,14 +274,14 @@
char* StringBuilder::Finalize() {
- ASSERT(!is_finalized() && position_ < size_);
+ ASSERT(!is_finalized() && position_ < buffer_.length());
buffer_[position_] = '\0';
// Make sure nobody managed to add a 0-character to the
// buffer while building the string.
- ASSERT(strlen(buffer_) == static_cast<size_t>(position_));
+ ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_));
position_ = -1;
ASSERT(is_finalized());
- return buffer_;
+ return buffer_.start();
}
} } // namespace v8::internal
« no previous file with comments | « src/utils.h ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698