本文整理汇总了C++中caml_alloc_custom函数的典型用法代码示例。如果您正苦于以下问题:C++ caml_alloc_custom函数的具体用法?C++ caml_alloc_custom怎么用?C++ caml_alloc_custom使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了caml_alloc_custom函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alloc_poll_mem
static value alloc_poll_mem(int n) {
struct pollfd *p;
value r;
p = caml_stat_alloc(n * sizeof(struct pollfd));
r = caml_alloc_custom(&poll_mem_ops, sizeof(p), n, 100000);
*(Poll_mem_val(r)) = p;
return r;
};
示例2: alloc_not_event
static value alloc_not_event(void) {
struct not_event *p;
value r;
p = caml_stat_alloc(sizeof(struct not_event));
r = caml_alloc_custom(¬_event_ops, sizeof(p), 0, 1);
*(Not_event_val(r)) = p;
return r;
};
示例3: alloc_poll_aggreg
static value alloc_poll_aggreg(void) {
struct poll_aggreg *p;
value r;
p = caml_stat_alloc(sizeof(struct poll_aggreg));
r = caml_alloc_custom(&poll_aggreg_ops, sizeof(p), 1, 0);
*(Poll_aggreg_val(r)) = p;
return r;
};
示例4: caml_alloc_channel
CAMLexport value caml_alloc_channel(struct channel *chan)
{
value res;
chan->refcount++; /* prevent finalization during next alloc */
res = caml_alloc_custom(&channel_operations, sizeof(struct channel *),
1, 1000);
Channel(res) = chan;
return res;
}
示例5: cf_wrap
value cf_wrap(CFTypeRef cf_value) {
CAMLparam0();
if (cf_value != NULL)
CFRetain(cf_value);
CAMLlocal1(block);
block = caml_alloc_custom(&cf_custom_ops, sizeof(CFTypeRef), 0, 1);
*((CFTypeRef*)Data_custom_val(block)) = cf_value;
CAMLreturn(block);
}
示例6: value_of_appsrc
static value value_of_appsrc(GstAppSrc *e)
{
value ans = caml_alloc_custom(&appsrc_ops, sizeof(appsrc*), 0, 1);
appsrc *as = malloc(sizeof(appsrc));
as->appsrc = e;
as->need_data_cb = 0;
as->need_data_hid = 0;
Appsrc_val(ans) = as;
return ans;
}
示例7: value_of_typefind_element
static value value_of_typefind_element(GstElement *e)
{
value ans = caml_alloc_custom(&typefind_element_ops, sizeof(typefind_element*), 0, 1);
typefind_element *tf = malloc(sizeof(typefind_element));
tf->tf = e;
tf->have_type_cb = 0;
tf->have_type_hid = 0;
Typefind_element_data_val(ans) = tf;
return ans;
}
示例8: value_of_appsink
static value value_of_appsink(GstAppSink *e)
{
value ans = caml_alloc_custom(&appsink_ops, sizeof(appsink*), 0, 1);
appsink *as = malloc(sizeof(appsink));
as->appsink = e;
as->new_sample_cb = 0;
as->new_sample_hid = 0;
Appsink_val(ans) = as;
return ans;
}
示例9: zlib_new_stream
/**
* Create an OCaml value containing a new z_stream pointer.
*
* This function may raise the following OCaml exception:
* - Out_of_memory exception
*
* @return {value} An OCaml value containing a new z_stream pointer.
*/
value zlib_new_stream() {
value z_streamp_val = caml_alloc_custom(&zlib_stream_ops, sizeof(z_streamp), 0, 1);
ZStreamP_val(z_streamp_val) = caml_stat_alloc(sizeof(z_stream));
ZStreamP_val(z_streamp_val)->zalloc = NULL;
ZStreamP_val(z_streamp_val)->zfree = NULL;
ZStreamP_val(z_streamp_val)->opaque = NULL;
ZStreamP_val(z_streamp_val)->next_in = NULL;
ZStreamP_val(z_streamp_val)->next_out = NULL;
return z_streamp_val;
}
示例10: value_of_bus
static value value_of_bus(GstBus *b)
{
if (!b) caml_raise_constant(*caml_named_value("gstreamer_exn_failure"));
value ans = caml_alloc_custom(&bus_ops, sizeof(bus_t*), 0, 1);
bus_t *bus = malloc(sizeof(bus));
bus->bus = b;
bus->element = 0;
caml_register_global_root(&bus->element);
Bus_data_val(ans) = bus;
return ans;
}
示例11: ffmpeg_stream_new_video
value
ffmpeg_stream_new_video(value ctx, value video_info_)
{
CAMLparam2(ctx, video_info_);
CAMLlocal1(stream);
stream = caml_alloc_tuple(StreamSize);
AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_H264);
int ret;
Stream_aux_direct_val(stream) = caml_alloc_custom(&streamaux_ops, sizeof(struct StreamAux), 0, 1);
Stream_aux_val(stream)->type = Val_int(STREAM_VIDEO);
Stream_context_direct_val(stream) = ctx;
Stream_aux_val(stream)->avstream = avformat_new_stream(Context_val(ctx)->fmtCtx, codec);
Stream_aux_val(stream)->avstream->codec->codec_id = AV_CODEC_ID_H264;
/* Stream_aux_val(stream)->avstream->codec->rc_min_rate = 50000; */
/* Stream_aux_val(stream)->avstream->codec->rc_max_rate = 200000; */
/* Stream_aux_val(stream)->avstream->codec->bit_rate = 10000; */
Stream_aux_val(stream)->avstream->codec->width = Int_val(Field(video_info_, 0));
Stream_aux_val(stream)->avstream->codec->height = Int_val(Field(video_info_, 1));
Stream_aux_val(stream)->avstream->codec->pix_fmt = AV_PIX_FMT_YUV420P;
//Stream_aux_val(stream)->avstream->codec->gop_size = 30;
if (Context_val(ctx)->fmtCtx->oformat->flags & AVFMT_GLOBALHEADER) {
Stream_aux_val(stream)->avstream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}
Stream_aux_val(stream)->avstream->time_base = (AVRational) {1, 10000};
AVDictionary* codecOpts = NULL;
/* av_dict_set(&codecOpts, "profile", "baseline", 0); */
/* av_dict_set(&codecOpts, "crf", "3", 0); */
/* av_dict_set(&codecOpts, "vbr", "1", 0); */
//av_dict_set(&codecOpts, "x264-params", "bitrate=2", 0);
//av_dict_set(&codecOpts, "x264-params", "crf=40:keyint=60:vbv_bufsize=40000:vbv_maxrate=150000", 0);
av_dict_set(&codecOpts, "x264-params", "crf=36:keyint=60", 0);
AVCodecContext* codecCtx = Stream_aux_val(stream)->avstream->codec;
caml_enter_blocking_section();
ret = avcodec_open2( codecCtx, codec, &codecOpts);
raise_and_leave_blocking_section_if_not(ret >= 0, ExnOpen, ret);
caml_leave_blocking_section();
assert(Stream_aux_val(stream)->avstream->codec->pix_fmt == AV_PIX_FMT_YUV420P);
Stream_aux_val(stream)->swsCtx =
sws_getContext(Stream_aux_val(stream)->avstream->codec->width, Stream_aux_val(stream)->avstream->codec->height, USER_PIXFORMAT,
Stream_aux_val(stream)->avstream->codec->width, Stream_aux_val(stream)->avstream->codec->height, Stream_aux_val(stream)->avstream->codec->pix_fmt,
0, NULL, NULL, NULL);
CAMLreturn((value) stream);
}
示例12: brlapiml_openConnectionWithHandle
CAMLprim value brlapiml_openConnectionWithHandle(value settings)
{
CAMLparam1(settings);
CAMLlocal1(handle);
brlapi_connectionSettings_t brlapiSettings;
brlapiSettings.auth = String_val(Field(settings, 0));
brlapiSettings.host = String_val(Field(settings, 1));
handle = caml_alloc_custom(&customOperations, brlapi_getHandleSize(), 0, 1);
if (brlapi__openConnection(Data_custom_val(handle), &brlapiSettings, &brlapiSettings)<0) raise_brlapi_error();
CAMLreturn(handle);
}
示例13: ctypes_allocate
/* allocate : int -> managed_buffer */
value ctypes_allocate(value size_)
{
CAMLparam1(size_);
int size = Int_val(size_);
CAMLlocal1(block);
block = caml_alloc_custom(&managed_buffer_custom_ops, sizeof(void*), 0, 1);
void *p = caml_stat_alloc(size);
void **d = (void **)Data_custom_val(block);
*d = p;
CAMLreturn(block);
}
示例14: camluv_copy_check
static value
camluv_copy_check(camluv_check_t *camluv_check)
{
CAMLparam0();
CAMLlocal1(check);
check = caml_alloc_custom(&camluv_check_struct_ops,
sizeof(camluv_check_t *), 0, 1);
camluv_check_struct_val(check) = camluv_check;
CAMLreturn(check);
}
示例15: camluv_copy_handle
static value
camluv_copy_handle(camluv_handle_t *camluv_handle)
{
CAMLparam0();
CAMLlocal1(handle);
handle = caml_alloc_custom(&camluv_handle_struct_ops,
sizeof(camluv_handle_t *), 0, 1);
camluv_handle_struct_val(handle) = camluv_handle;
CAMLreturn(handle);
}