Chromium Code Reviews| Index: runtime/bin/utils.h |
| diff --git a/runtime/bin/utils.h b/runtime/bin/utils.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..16cdd4b5708b94a9798e8cbfaf7dc123442b45b5 |
| --- /dev/null |
| +++ b/runtime/bin/utils.h |
| @@ -0,0 +1,39 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#ifndef BIN_UTILS_H_ |
| +#define BIN_UTILS_H_ |
| + |
| +#include <stdlib.h> |
| +#include <string.h> |
| + |
| +#include "include/dart_api.h" |
| +#include "platform/globals.h" |
| + |
| +class OSError { |
| + public: |
| + OSError(); |
| + OSError(int code, char* message) { |
| + code_ = code; |
| + SetMessage(message); |
| + } |
| + virtual ~OSError() { free(message_); } |
| + |
| + int code() { return code_; } |
| + void set_code(int code) { code_ = code; } |
| + char* message() { return message_; } |
| + void SetMessage(char* message) { |
| + free(message_); |
| + message_ = NULL; |
|
Mads Ager (google)
2012/03/13 10:56:17
Redundant because of the next line.
Søren Gjesse
2012/03/13 12:39:49
Added NULL check.
|
| + message_ = strdup(message); |
| + } |
| + |
| + private: |
| + int code_; |
| + char* message_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OSError); |
| +}; |
| + |
| +#endif // BIN_UTILS_H_ |