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