OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
| 11 #include "webrtc/base/flags.h" |
| 12 |
11 #include <stdio.h> | 13 #include <stdio.h> |
12 #include <stdlib.h> | 14 #include <stdlib.h> |
13 #include <string.h> | 15 #include <string.h> |
14 | 16 |
| 17 #include "webrtc/base/checks.h" |
15 | 18 |
16 #if defined(WEBRTC_WIN) | 19 #if defined(WEBRTC_WIN) |
17 #include "webrtc/base/win32.h" | 20 #include "webrtc/base/win32.h" |
18 #include <shellapi.h> | 21 #include <shellapi.h> |
19 #endif | 22 #endif |
20 | 23 |
21 #include "webrtc/base/flags.h" | |
22 | |
23 namespace rtc { | 24 namespace rtc { |
24 // ----------------------------------------------------------------------------- | 25 // ----------------------------------------------------------------------------- |
25 // Implementation of Flag | 26 // Implementation of Flag |
26 | 27 |
27 Flag::Flag(const char* file, const char* name, const char* comment, | 28 Flag::Flag(const char* file, const char* name, const char* comment, |
28 Type type, void* variable, FlagValue default__) | 29 Type type, void* variable, FlagValue default__) |
29 : file_(file), | 30 : file_(file), |
30 name_(name), | 31 name_(name), |
31 comment_(comment), | 32 comment_(comment), |
32 type_(type), | 33 type_(type), |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 argv[j++] = argv[i]; | 250 argv[j++] = argv[i]; |
250 } | 251 } |
251 *argc = j; | 252 *argc = j; |
252 } | 253 } |
253 | 254 |
254 // parsed all flags successfully | 255 // parsed all flags successfully |
255 return 0; | 256 return 0; |
256 } | 257 } |
257 | 258 |
258 void FlagList::Register(Flag* flag) { | 259 void FlagList::Register(Flag* flag) { |
259 assert(flag != NULL && strlen(flag->name()) > 0); | 260 RTC_DCHECK(flag); |
| 261 RTC_DCHECK_GT(strlen(flag->name()), 0u); |
260 // NOTE: Don't call Lookup() within Register because it accesses the name_ | 262 // NOTE: Don't call Lookup() within Register because it accesses the name_ |
261 // of other flags in list_, and if the flags are coming from two different | 263 // of other flags in list_, and if the flags are coming from two different |
262 // compilation units, the initialization order between them is undefined, and | 264 // compilation units, the initialization order between them is undefined, and |
263 // this will trigger an asan initialization-order-fiasco error. | 265 // this will trigger an asan initialization-order-fiasco error. |
264 flag->next_ = list_; | 266 flag->next_ = list_; |
265 list_ = flag; | 267 list_ = flag; |
266 } | 268 } |
267 | 269 |
268 #if defined(WEBRTC_WIN) | 270 #if defined(WEBRTC_WIN) |
269 WindowsCommandLineArguments::WindowsCommandLineArguments() { | 271 WindowsCommandLineArguments::WindowsCommandLineArguments() { |
(...skipping 20 matching lines...) Expand all Loading... |
290 // need to free each string in the array, and then the array. | 292 // need to free each string in the array, and then the array. |
291 for(int i = 0; i < argc_; i++) { | 293 for(int i = 0; i < argc_; i++) { |
292 delete[] argv_[i]; | 294 delete[] argv_[i]; |
293 } | 295 } |
294 | 296 |
295 delete[] argv_; | 297 delete[] argv_; |
296 } | 298 } |
297 #endif // WEBRTC_WIN | 299 #endif // WEBRTC_WIN |
298 | 300 |
299 } // namespace rtc | 301 } // namespace rtc |
OLD | NEW |