Pepper_31_C_interfaces
Public Attributes | List of all members
PP_ArrayOutput Struct Reference

#include <pp_array_output.h>

Collaboration diagram for PP_ArrayOutput:
Collaboration graph

Public Attributes

PP_ArrayOutput_GetDataBuffer GetDataBuffer
 
void * user_data
 

Detailed Description

A structure that defines a way for the browser to return arrays of data to the plugin. The browser can not allocate memory on behalf of the plugin because the plugin and browser may have different allocators.

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.

In C, you would typically implement this as follows:

struct MyArrayOutput {
void* data;
int element_count;
};
void* MyGetDataBuffer(void* user_data, uint32_t count, uint32_t size) {
MyArrayOutput* output = (MyArrayOutput*)user_data;
output->element_count = count;
if (size) {
output->data = malloc(count * size);
if (!output->data) // Be careful to set size properly on malloc failure.
output->element_count = 0;
} else {
output->data = NULL;
}
return output->data;
}
void MyFunction() {
MyArrayOutput array = { NULL, 0 };
PP_ArrayOutput output = { &MyGetDataBuffer, &array };
ppb_foo->GetData(&output);
}

Definition at line 100 of file pp_array_output.h.

Member Data Documentation

PP_ArrayOutput_GetDataBuffer PP_ArrayOutput::GetDataBuffer

A pointer to the allocation function that the browser implements.

Definition at line 104 of file pp_array_output.h.

void* PP_ArrayOutput::user_data

Data that is passed to the allocation function. Typically, this is used to communicate how the data should be stored.

Definition at line 109 of file pp_array_output.h.


The documentation for this struct was generated from the following file: