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

Side by Side Diff: third_party/base/stl_util.h

Issue 1388203003: Sanitize CJBig2_SymbolDict's memory usage. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 2 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
« no previous file with comments | « third_party/BUILD.gn ('k') | third_party/third_party.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
6 #define PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
7
8 #include <vector>
9
10 namespace pdfium {
11
12 // To treat a possibly-empty vector as an array, use these functions.
13 // If you know the array will never be empty, you can use &*v.begin()
14 // directly, but that is undefined behaviour if |v| is empty.
15 template <typename T>
16 inline T* vector_as_array(std::vector<T>* v) {
17 return v->empty() ? nullptr : &*v->begin();
18 }
19
20 template <typename T>
21 inline const T* vector_as_array(const std::vector<T>* v) {
22 return v->empty() ? nullptr : &*v->begin();
23 }
24
25 } // namespace pdfium
26
27 #endif // PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
OLDNEW
« no previous file with comments | « third_party/BUILD.gn ('k') | third_party/third_party.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698