Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BIN_UTILS_H_ | |
| 6 #define BIN_UTILS_H_ | |
| 7 | |
| 8 #include <stdlib.h> | |
| 9 #include <string.h> | |
| 10 | |
| 11 #include "include/dart_api.h" | |
| 12 #include "platform/globals.h" | |
| 13 | |
| 14 class OSError { | |
| 15 public: | |
| 16 OSError(); | |
| 17 OSError(int code, char* message) { | |
| 18 code_ = code; | |
| 19 SetMessage(message); | |
| 20 } | |
| 21 virtual ~OSError() { free(message_); } | |
| 22 | |
| 23 int code() { return code_; } | |
| 24 void set_code(int code) { code_ = code; } | |
| 25 char* message() { return message_; } | |
| 26 void SetMessage(char* message) { | |
| 27 free(message_); | |
| 28 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.
| |
| 29 message_ = strdup(message); | |
| 30 } | |
| 31 | |
| 32 private: | |
| 33 int code_; | |
| 34 char* message_; | |
| 35 | |
| 36 DISALLOW_COPY_AND_ASSIGN(OSError); | |
| 37 }; | |
| 38 | |
| 39 #endif // BIN_UTILS_H_ | |
| OLD | NEW |