Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / doc_generated / pepper_beta / c / struct_p_p___array_output.html
1 {{+bindTo:partials.standard_nacl_article}}
2 <h1>PP_ArrayOutput Struct Reference</h1>
3 <div>
4 <!-- Generated by Doxygen 1.7.6.1 -->
5
6
7 </div>
8 <!--header-->
9 <div class="contents">
10 <!-- doxytag: class="PP_ArrayOutput" --><h2>
11 Data Fields</h2><table class="memberdecls">
12
13 <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___typedefs.html#gaa363de651fad7342a37ec58375276af7">PP_ArrayOutput_GetDataBuffer</a>&#160;</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 *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p___array_output.html#a6323083ee2b06f902c9c334c6b10a6d0">user_data</a></td></tr>
15 </table>
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;
24  };
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-&gt;element_count = count;
28    <span class="keywordflow">if</span> (size) {
29      output-&gt;data = malloc(count * size);
30      <span class="keywordflow">if</span> (!output-&gt;data)  <span class="comment">// Be careful to set size properly on malloc failure.</span>
31        output-&gt;element_count = 0;
32    } <span class="keywordflow">else</span> {
33      output-&gt;data = NULL;
34    }
35    <span class="keywordflow">return</span> output-&gt;data;
36  }
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 = { &amp;MyGetDataBuffer, &amp;array };
40    ppb_foo-&gt;GetData(&amp;output);
41  }
42 </pre></div> </div><hr /><h2>Field Documentation</h2>
43 <a class="anchor" id="acfd88c0475e6518cc9ed058c85744c58"></a><!-- doxytag: member="PP_ArrayOutput::GetDataBuffer" ref="acfd88c0475e6518cc9ed058c85744c58" args="" -->
44 <div class="memitem">
45 <div class="memproto">
46 <table class="memname">
47 <tr>
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>
49 </tr>
50 </table>
51 </div>
52 <div class="memdoc">
53 <p>A pointer to the allocation function that the browser will call. </p>
54 </div>
55 </div>
56 <a class="anchor" id="a6323083ee2b06f902c9c334c6b10a6d0"></a><!-- doxytag: member="PP_ArrayOutput::user_data" ref="a6323083ee2b06f902c9c334c6b10a6d0" args="" -->
57 <div class="memitem">
58 <div class="memproto">
59 <table class="memname">
60 <tr>
61 <td class="memname">void* <a class="el" href="struct_p_p___array_output.html#a6323083ee2b06f902c9c334c6b10a6d0">PP_ArrayOutput::user_data</a></td>
62 </tr>
63 </table>
64 </div>
65 <div class="memdoc">
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>
68 </div>
69 </div>
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>
72 </ul>
73 </div><!-- contents -->
74 {{/partials.standard_nacl_article}}