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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc

Issue 574803002: [NaCl SDK] nacl_io: Fix excess realloc'ing in memfs nodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "nacl_io/memfs/mem_fs.h" 5 #include "nacl_io/memfs/mem_fs.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 // Directories can only be opened read-only. 108 // Directories can only be opened read-only.
109 if (node->IsaDir() && (open_flags & 3) != O_RDONLY) 109 if (node->IsaDir() && (open_flags & 3) != O_RDONLY)
110 return EISDIR; 110 return EISDIR;
111 111
112 // If we were expected to create it exclusively, fail 112 // If we were expected to create it exclusively, fail
113 if (open_flags & O_EXCL) 113 if (open_flags & O_EXCL)
114 return EEXIST; 114 return EEXIST;
115 115
116 if (open_flags & O_TRUNC) 116 if (open_flags & O_TRUNC)
117 static_cast<MemFsNode*>(node.get())->Resize(0); 117 node->FTruncate(0);
118 } 118 }
119 119
120 *out_node = node; 120 *out_node = node;
121 return 0; 121 return 0;
122 } 122 }
123 123
124 Error MemFs::Mkdir(const Path& path, int mode) { 124 Error MemFs::Mkdir(const Path& path, int mode) {
125 // We expect a Filesystem "absolute" path 125 // We expect a Filesystem "absolute" path
126 if (!path.IsAbsolute()) 126 if (!path.IsAbsolute())
127 return ENOENT; 127 return ENOENT;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (file_only && child->IsaDir()) 267 if (file_only && child->IsaDir())
268 return EISDIR; 268 return EISDIR;
269 269
270 if (remove_dir && child->ChildCount() > 0) 270 if (remove_dir && child->ChildCount() > 0)
271 return ENOTEMPTY; 271 return ENOTEMPTY;
272 272
273 return parent->RemoveChild(path.Basename()); 273 return parent->RemoveChild(path.Basename());
274 } 274 }
275 275
276 } // namespace nacl_io 276 } // namespace nacl_io
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698