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

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

Issue 42329: Getting rid of OS::StrDup and OS::StrNDup which were sometimes misused. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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.h ('k') | src/platform-linux.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 char* OS::StrChr(char* str, int c) { 192 char* OS::StrChr(char* str, int c) {
193 return strchr(str, c); 193 return strchr(str, c);
194 } 194 }
195 195
196 196
197 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { 197 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
198 strncpy(dest.start(), src, n); 198 strncpy(dest.start(), src, n);
199 } 199 }
200 200
201 201
202 char *OS::StrDup(const char* str) {
203 return strdup(str);
204 }
205
206
207 char* OS::StrNDup(const char* str, size_t n) {
208 // Stupid implementation of strndup since freebsd isn't born with
209 // one.
210 size_t len = strlen(str);
211 if (len <= n) {
212 return StrDup(str);
213 }
214 char* result = new char[n+1];
215 size_t i;
216 for (i = 0; i <= n; i++) {
217 result[i] = str[i];
218 }
219 result[i] = '\0';
220 return result;
221 }
222
223
224 double OS::nan_value() { 202 double OS::nan_value() {
225 return NAN; 203 return NAN;
226 } 204 }
227 205
228 206
229 int OS::ActivationFrameAlignment() { 207 int OS::ActivationFrameAlignment() {
230 // 16 byte alignment on FreeBSD 208 // 16 byte alignment on FreeBSD
231 return 16; 209 return 16;
232 } 210 }
233 211
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 } 848 }
871 849
872 // This sampler is no longer the active sampler. 850 // This sampler is no longer the active sampler.
873 active_sampler_ = NULL; 851 active_sampler_ = NULL;
874 active_ = false; 852 active_ = false;
875 } 853 }
876 854
877 #endif // ENABLE_LOGGING_AND_PROFILING 855 #endif // ENABLE_LOGGING_AND_PROFILING
878 856
879 } } // namespace v8::internal 857 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698