| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 if (result == NULL) { | 99 if (result == NULL) { |
| 100 // Allocate the initial result and make room for the terminating '\0' | 100 // Allocate the initial result and make room for the terminating '\0' |
| 101 result = NewArray<char>(len + 1); | 101 result = NewArray<char>(len + 1); |
| 102 } else { | 102 } else { |
| 103 // Allocate a new result with enough room for the new addition. | 103 // Allocate a new result with enough room for the new addition. |
| 104 int new_len = offset + len + 1; | 104 int new_len = offset + len + 1; |
| 105 char* new_result = NewArray<char>(new_len); | 105 char* new_result = NewArray<char>(new_len); |
| 106 // Copy the existing input into the new array and set the new | 106 // Copy the existing input into the new array and set the new |
| 107 // array as the result. | 107 // array as the result. |
| 108 memcpy(new_result, result, offset * kCharSize); | 108 OS::MemCopy(new_result, result, offset * kCharSize); |
| 109 DeleteArray(result); | 109 DeleteArray(result); |
| 110 result = new_result; | 110 result = new_result; |
| 111 } | 111 } |
| 112 // Copy the newly read line into the result. | 112 // Copy the newly read line into the result. |
| 113 memcpy(result + offset, line_buf, len * kCharSize); | 113 OS::MemCopy(result + offset, line_buf, len * kCharSize); |
| 114 offset += len; | 114 offset += len; |
| 115 } | 115 } |
| 116 ASSERT(result != NULL); | 116 ASSERT(result != NULL); |
| 117 result[offset] = '\0'; | 117 result[offset] = '\0'; |
| 118 return result; | 118 return result; |
| 119 } | 119 } |
| 120 | 120 |
| 121 | 121 |
| 122 char* ReadCharsFromFile(FILE* file, | 122 char* ReadCharsFromFile(FILE* file, |
| 123 int* size, | 123 int* size, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 ASSERT(!is_finalized() && position_ < buffer_.length()); | 267 ASSERT(!is_finalized() && position_ < buffer_.length()); |
| 268 int n = OS::VSNPrintF(buffer_ + position_, format, list); | 268 int n = OS::VSNPrintF(buffer_ + position_, format, list); |
| 269 if (n < 0 || n >= (buffer_.length() - position_)) { | 269 if (n < 0 || n >= (buffer_.length() - position_)) { |
| 270 position_ = buffer_.length(); | 270 position_ = buffer_.length(); |
| 271 } else { | 271 } else { |
| 272 position_ += n; | 272 position_ += n; |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 } } // namespace v8::internal | 276 } } // namespace v8::internal |
| OLD | NEW |