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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc

Issue 443693002: [NaCl SDK] nacl_io: Remove use of new/delete for data buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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/httpfs/http_fs.h" 5 #include "nacl_io/httpfs/http_fs.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <ctype.h> 8 #include <ctype.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 url_root_ += '/'; 219 url_root_ += '/';
220 } 220 }
221 } else if (iter->first == "manifest") { 221 } else if (iter->first == "manifest") {
222 char* text; 222 char* text;
223 error = LoadManifest(iter->second, &text); 223 error = LoadManifest(iter->second, &text);
224 if (error) 224 if (error)
225 return error; 225 return error;
226 226
227 error = ParseManifest(text); 227 error = ParseManifest(text);
228 if (error) { 228 if (error) {
229 delete[] text; 229 free(text);
230 return error; 230 return error;
231 } 231 }
232 232
233 delete[] text; 233 free(text);
234 } else if (iter->first == "allow_cross_origin_requests") { 234 } else if (iter->first == "allow_cross_origin_requests") {
235 allow_cors_ = iter->second == "true"; 235 allow_cors_ = iter->second == "true";
236 } else if (iter->first == "allow_credentials") { 236 } else if (iter->first == "allow_credentials") {
237 allow_credentials_ = iter->second == "true"; 237 allow_credentials_ = iter->second == "true";
238 } else if (iter->first == "cache_stat") { 238 } else if (iter->first == "cache_stat") {
239 cache_stat_ = iter->second == "true"; 239 cache_stat_ = iter->second == "true";
240 } else if (iter->first == "cache_content") { 240 } else if (iter->first == "cache_content") {
241 cache_content_ = iter->second == "true"; 241 cache_content_ = iter->second == "true";
242 } else { 242 } else {
243 // Assume it is a header to pass to an HTTP request. 243 // Assume it is a header to pass to an HTTP request.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 int error = Open(manifest_path, O_RDONLY, &manifest_node); 390 int error = Open(manifest_path, O_RDONLY, &manifest_node);
391 if (error) 391 if (error)
392 return error; 392 return error;
393 393
394 off_t size; 394 off_t size;
395 error = manifest_node->GetSize(&size); 395 error = manifest_node->GetSize(&size);
396 if (error) 396 if (error)
397 return error; 397 return error;
398 398
399 char* text = new char[size + 1]; 399 char* text = (char*)malloc(size + 1);
400 assert(text != NULL);
401 if (text == NULL)
402 return ENOMEM;
400 int len; 403 int len;
401 error = manifest_node->Read(HandleAttr(), text, size, &len); 404 error = manifest_node->Read(HandleAttr(), text, size, &len);
402 if (error) 405 if (error)
403 return error; 406 return error;
404 407
405 text[len] = 0; 408 text[len] = 0;
406 *out_manifest = text; 409 *out_manifest = text;
407 return 0; 410 return 0;
408 } 411 }
409 412
410 std::string HttpFs::MakeUrl(const Path& path) { 413 std::string HttpFs::MakeUrl(const Path& path) {
411 return url_root_ + 414 return url_root_ +
412 (path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join()); 415 (path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join());
413 } 416 }
414 417
415 } // namespace nacl_io 418 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/fifo_char.cc ('k') | native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698