| {{+bindTo:partials.standard_nacl_api}} |
| <h1>PP_ArrayOutput Struct Reference</h1> |
| <div id="doxygen-ref"> |
| {{- dummy div to appease doxygen -}} |
| <div> |
| <!-- Generated by Doxygen 1.7.6.1 --> |
| |
| |
| </div> |
| <!--header--> |
| <div class="contents"> |
| <!-- doxytag: class="PP_ArrayOutput" --><h2> |
| Data Fields</h2><table class="memberdecls"> |
| |
| <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___typedefs.html#gaa363de651fad7342a37ec58375276af7">PP_ArrayOutput_GetDataBuffer</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p___array_output.html#acfd88c0475e6518cc9ed058c85744c58">GetDataBuffer</a></td></tr> |
| <tr><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p___array_output.html#a6323083ee2b06f902c9c334c6b10a6d0">user_data</a></td></tr> |
| </table> |
| <hr /><a name="details" id="details"></a><h2>Detailed Description</h2> |
| <div class="textblock"><p>A structure that defines a way for the browser to return arrays of data to the plugin. </p> |
| <p>The browser can not allocate memory on behalf of the plugin because the plugin and browser may have different allocators.</p> |
| <p>Array output works by having the browser call to the plugin to allocate a buffer, and then the browser will copy the contents of the array into that buffer.</p> |
| <p>In C, you would typically implement this as follows:</p> |
| <div class="fragment"><pre class="fragment"> <span class="keyword">struct </span>MyArrayOutput { |
| <span class="keywordtype">void</span>* data; |
| <span class="keywordtype">int</span> element_count; |
| }; |
| <span class="keywordtype">void</span>* MyGetDataBuffer(<span class="keywordtype">void</span>* <a class="code" href="struct_p_p___array_output.html#a6323083ee2b06f902c9c334c6b10a6d0" title="Data that is passed to the allocation function.">user_data</a>, uint32_t count, uint32_t size) { |
| MyArrayOutput* output = (MyArrayOutput*)user_data; |
| output->element_count = count; |
| <span class="keywordflow">if</span> (size) { |
| output->data = malloc(count * size); |
| <span class="keywordflow">if</span> (!output->data) <span class="comment">// Be careful to set size properly on malloc failure.</span> |
| output->element_count = 0; |
| } <span class="keywordflow">else</span> { |
| output->data = NULL; |
| } |
| <span class="keywordflow">return</span> output->data; |
| } |
| <span class="keywordtype">void</span> MyFunction() { |
| MyArrayOutput array = { NULL, 0 }; |
| <a class="code" href="struct_p_p___array_output.html" title="A structure that defines a way for the browser to return arrays of data to the plugin.">PP_ArrayOutput</a> output = { &MyGetDataBuffer, &array }; |
| ppb_foo->GetData(&output); |
| } |
| </pre></div> </div><hr /><h2>Field Documentation</h2> |
| <a class="anchor" id="acfd88c0475e6518cc9ed058c85744c58"></a><!-- doxytag: member="PP_ArrayOutput::GetDataBuffer" ref="acfd88c0475e6518cc9ed058c85744c58" args="" --> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group___typedefs.html#gaa363de651fad7342a37ec58375276af7">PP_ArrayOutput_GetDataBuffer</a> <a class="el" href="struct_p_p___array_output.html#acfd88c0475e6518cc9ed058c85744c58">PP_ArrayOutput::GetDataBuffer</a></td> |
| </tr> |
| </table> |
| </div> |
| <div class="memdoc"> |
| <p>A pointer to the allocation function that the browser will call. </p> |
| </div> |
| </div> |
| <a class="anchor" id="a6323083ee2b06f902c9c334c6b10a6d0"></a><!-- doxytag: member="PP_ArrayOutput::user_data" ref="a6323083ee2b06f902c9c334c6b10a6d0" args="" --> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname">void* <a class="el" href="struct_p_p___array_output.html#a6323083ee2b06f902c9c334c6b10a6d0">PP_ArrayOutput::user_data</a></td> |
| </tr> |
| </table> |
| </div> |
| <div class="memdoc"> |
| <p>Data that is passed to the allocation function. </p> |
| <p>Typically, this is used to communicate how the data should be stored. </p> |
| </div> |
| </div> |
| <hr />The documentation for this struct was generated from the following file:<ul> |
| <li><a class="el" href="pp__array__output_8h.html">pp_array_output.h</a></li> |
| </ul> |
| </div><!-- contents --> |
| </div> |
| {{/partials.standard_nacl_api}} |