Remove all npapi plugins from windows metro chrome
[chromium-blink-merge.git] / base / safe_strerror_posix.h
blob60fdec32ee8f4726c29c9e6d444df4c98dc2d248
1 // Copyright (c) 2011 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.
5 #ifndef BASE_SAFE_STRERROR_POSIX_H_
6 #define BASE_SAFE_STRERROR_POSIX_H_
7 #pragma once
9 #include <string>
11 #include "base/base_export.h"
13 // BEFORE using anything from this file, first look at PLOG and friends in
14 // logging.h and use them instead if applicable.
16 // This file declares safe, portable alternatives to the POSIX strerror()
17 // function. strerror() is inherently unsafe in multi-threaded apps and should
18 // never be used. Doing so can cause crashes. Additionally, the thread-safe
19 // alternative strerror_r varies in semantics across platforms. Use these
20 // functions instead.
22 // Thread-safe strerror function with dependable semantics that never fails.
23 // It will write the string form of error "err" to buffer buf of length len.
24 // If there is an error calling the OS's strerror_r() function then a message to
25 // that effect will be printed into buf, truncating if necessary. The final
26 // result is always null-terminated. The value of errno is never changed.
28 // Use this instead of strerror_r().
29 BASE_EXPORT void safe_strerror_r(int err, char *buf, size_t len);
31 // Calls safe_strerror_r with a buffer of suitable size and returns the result
32 // in a C++ string.
34 // Use this instead of strerror(). Note though that safe_strerror_r will be
35 // more robust in the case of heap corruption errors, since it doesn't need to
36 // allocate a string.
37 BASE_EXPORT std::string safe_strerror(int err);
39 #endif // BASE_SAFE_STRERROR_POSIX_H_