1 {{+bindTo:partials.standard_nacl_article}}
2 <h1>PP_ArrayOutput Struct Reference</h1>
4 <!-- Generated by Doxygen 1.7.6.1 -->
10 <!-- doxytag: class="PP_ArrayOutput" --><h2>
11 Data Fields</h2><table class="memberdecls">
13 <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>
14 <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>
16 <hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
17 <div class="textblock"><p>A structure that defines a way for the browser to return arrays of data to the plugin. </p>
18 <p>The browser can not allocate memory on behalf of the plugin because the plugin and browser may have different allocators.</p>
19 <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>
20 <p>In C, you would typically implement this as follows:</p>
21 <div class="fragment"><pre class="fragment"> <span class="keyword">struct </span>MyArrayOutput {
22 <span class="keywordtype">void</span>* data;
23 <span class="keywordtype">int</span> element_count;
25 <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) {
26 MyArrayOutput* output = (MyArrayOutput*)user_data;
27 output->element_count = count;
28 <span class="keywordflow">if</span> (size) {
29 output->data = malloc(count * size);
30 <span class="keywordflow">if</span> (!output->data) <span class="comment">// Be careful to set size properly on malloc failure.</span>
31 output->element_count = 0;
32 } <span class="keywordflow">else</span> {
33 output->data = NULL;
35 <span class="keywordflow">return</span> output->data;
37 <span class="keywordtype">void</span> MyFunction() {
38 MyArrayOutput array = { NULL, 0 };
39 <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 };
40 ppb_foo->GetData(&output);
42 </pre></div> </div><hr /><h2>Field Documentation</h2>
43 <a class="anchor" id="acfd88c0475e6518cc9ed058c85744c58"></a><!-- doxytag: member="PP_ArrayOutput::GetDataBuffer" ref="acfd88c0475e6518cc9ed058c85744c58" args="" -->
45 <div class="memproto">
46 <table class="memname">
48 <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>
53 <p>A pointer to the allocation function that the browser will call. </p>
56 <a class="anchor" id="a6323083ee2b06f902c9c334c6b10a6d0"></a><!-- doxytag: member="PP_ArrayOutput::user_data" ref="a6323083ee2b06f902c9c334c6b10a6d0" args="" -->
58 <div class="memproto">
59 <table class="memname">
61 <td class="memname">void* <a class="el" href="struct_p_p___array_output.html#a6323083ee2b06f902c9c334c6b10a6d0">PP_ArrayOutput::user_data</a></td>
66 <p>Data that is passed to the allocation function. </p>
67 <p>Typically, this is used to communicate how the data should be stored. </p>
70 <hr />The documentation for this struct was generated from the following file:<ul>
71 <li><a class="el" href="pp__array__output_8h.html">pp_array_output.h</a></li>
73 </div><!-- contents -->
74 {{/partials.standard_nacl_article}}