OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef __STDC_LIMIT_MACROS | 5 #ifndef __STDC_LIMIT_MACROS |
6 #define __STDC_LIMIT_MACROS | 6 #define __STDC_LIMIT_MACROS |
7 #endif | 7 #endif |
8 | 8 |
9 #include "nacl_io/memfs/mem_fs_node.h" | 9 #include "nacl_io/memfs/mem_fs_node.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 MemFsNode::MemFsNode(Filesystem* filesystem) | 32 MemFsNode::MemFsNode(Filesystem* filesystem) |
33 : Node(filesystem), | 33 : Node(filesystem), |
34 data_(NULL), | 34 data_(NULL), |
35 data_capacity_(0) { | 35 data_capacity_(0) { |
36 SetType(S_IFREG); | 36 SetType(S_IFREG); |
37 } | 37 } |
38 | 38 |
39 MemFsNode::~MemFsNode() { | 39 MemFsNode::~MemFsNode() { |
| 40 free(data_); |
40 } | 41 } |
41 | 42 |
42 Error MemFsNode::Read(const HandleAttr& attr, | 43 Error MemFsNode::Read(const HandleAttr& attr, |
43 void* buf, | 44 void* buf, |
44 size_t count, | 45 size_t count, |
45 int* out_bytes) { | 46 int* out_bytes) { |
46 *out_bytes = 0; | 47 *out_bytes = 0; |
47 | 48 |
48 AUTO_LOCK(node_lock_); | 49 AUTO_LOCK(node_lock_); |
49 if (count == 0) | 50 if (count == 0) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 data_capacity_ = new_capacity; | 117 data_capacity_ = new_capacity; |
117 } | 118 } |
118 | 119 |
119 if (new_length > stat_.st_size) | 120 if (new_length > stat_.st_size) |
120 memset(data_ + stat_.st_size, 0, new_length - stat_.st_size); | 121 memset(data_ + stat_.st_size, 0, new_length - stat_.st_size); |
121 stat_.st_size = new_length; | 122 stat_.st_size = new_length; |
122 return 0; | 123 return 0; |
123 } | 124 } |
124 | 125 |
125 } // namespace nacl_io | 126 } // namespace nacl_io |
OLD | NEW |