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

Side by Side Diff: native_client_sdk/src/examples/demo/nacl_io/nacl_io_demo.c

Issue 22842011: [NaCl SDK] Remove invalid assert from nacl_io. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2012 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 5
6 #include "nacl_io_demo.h" 6 #include "nacl_io_demo.h"
7 7
8 #include <assert.h> 8 #include <assert.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 char* VprintfToNewString(const char* format, va_list args) { 79 char* VprintfToNewString(const char* format, va_list args) {
80 va_list args_copy; 80 va_list args_copy;
81 int length; 81 int length;
82 char* buffer; 82 char* buffer;
83 int result; 83 int result;
84 84
85 va_copy(args_copy, args); 85 va_copy(args_copy, args);
86 length = vsnprintf(NULL, 0, format, args); 86 length = vsnprintf(NULL, 0, format, args);
87 buffer = (char*)malloc(length + 1); /* +1 for NULL-terminator. */ 87 buffer = (char*)malloc(length + 1); /* +1 for NULL-terminator. */
88 result = vsnprintf(&buffer[0], length + 1, format, args_copy); 88 result = vsnprintf(&buffer[0], length + 1, format, args_copy);
89 assert(result == length); 89 if (result != length) {
90 assert(0);
91 return NULL;
92 }
90 return buffer; 93 return buffer;
91 } 94 }
92 95
93 /** 96 /**
94 * Printf to a newly allocated C string. 97 * Printf to a newly allocated C string.
95 * @param[in] format A print format string. 98 * @param[in] format A print format string.
96 * @param[in] ... The printf arguments. 99 * @param[in] ... The printf arguments.
97 * @return The newly constructed string. Caller takes ownership. */ 100 * @return The newly constructed string. Caller takes ownership. */
98 char* PrintfToNewString(const char* format, ...) { 101 char* PrintfToNewString(const char* format, ...) {
99 va_list args; 102 va_list args;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } else if (strcmp(interface_name, PPP_MESSAGING_INTERFACE) == 0) { 360 } else if (strcmp(interface_name, PPP_MESSAGING_INTERFACE) == 0) {
358 static PPP_Messaging messaging_interface = { 361 static PPP_Messaging messaging_interface = {
359 &Messaging_HandleMessage, 362 &Messaging_HandleMessage,
360 }; 363 };
361 return &messaging_interface; 364 return &messaging_interface;
362 } 365 }
363 return NULL; 366 return NULL;
364 } 367 }
365 368
366 PP_EXPORT void PPP_ShutdownModule() {} 369 PP_EXPORT void PPP_ShutdownModule() {}
OLDNEW
« no previous file with comments | « native_client_sdk/src/examples/api/input_event/shared_queue.h ('k') | native_client_sdk/src/examples/demo/voronoi/voronoi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698