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

Side by Side Diff: src/platform-macos.cc

Issue 18585: Handle strndup in freebsd in the same way it is handled on other... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 char* OS::StrDup(const char* str) { 193 char* OS::StrDup(const char* str) {
194 return strdup(str); 194 return strdup(str);
195 } 195 }
196 196
197 197
198 char* OS::StrNDup(const char* str, size_t n) { 198 char* OS::StrNDup(const char* str, size_t n) {
199 // Stupid implementation of strndup since macos isn't born with 199 // Stupid implementation of strndup since macos isn't born with
200 // one. 200 // one.
201 size_t len = strlen(str); 201 size_t len = strlen(str);
202 if (len <= n) 202 if (len <= n) {
203 return StrDup(str); 203 return StrDup(str);
204 }
204 char* result = new char[n+1]; 205 char* result = new char[n+1];
205 size_t i; 206 size_t i;
206 for (i = 0; i <= n; i++) 207 for (i = 0; i <= n; i++) {
207 result[i] = str[i]; 208 result[i] = str[i];
209 }
208 result[i] = '\0'; 210 result[i] = '\0';
209 return result; 211 return result;
210 } 212 }
211 213
212 214
213 // We keep the lowest and highest addresses mapped as a quick way of 215 // We keep the lowest and highest addresses mapped as a quick way of
214 // determining that pointers are outside the heap (used mostly in assertions 216 // determining that pointers are outside the heap (used mostly in assertions
215 // and verification). The estimate is conservative, ie, not all addresses in 217 // and verification). The estimate is conservative, ie, not all addresses in
216 // 'allocated' space are actually allocated to our heap. The range is 218 // 'allocated' space are actually allocated to our heap. The range is
217 // [lowest, highest), inclusive on the low and and exclusive on the high end. 219 // [lowest, highest), inclusive on the low and and exclusive on the high end.
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 } 655 }
654 656
655 // This sampler is no longer the active sampler. 657 // This sampler is no longer the active sampler.
656 active_sampler_ = NULL; 658 active_sampler_ = NULL;
657 active_ = false; 659 active_ = false;
658 } 660 }
659 661
660 #endif // ENABLE_LOGGING_AND_PROFILING 662 #endif // ENABLE_LOGGING_AND_PROFILING
661 663
662 } } // namespace v8::internal 664 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698