本文整理汇总了C++中caml_alloc_custom函数的典型用法代码示例。如果您正苦于以下问题:C++ caml_alloc_custom函数的具体用法?C++ caml_alloc_custom怎么用?C++ caml_alloc_custom使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了caml_alloc_custom函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
};
开发者ID:cakeplus,项目名称:ocamlnet,代码行数:8,代码来源:netsys_c_poll.c
示例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;
};
开发者ID:flashfoxter,项目名称:libres3,代码行数:8,代码来源:netsys_c_event.c
示例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;
};
开发者ID:cakeplus,项目名称:ocamlnet,代码行数:8,代码来源:netsys_c_poll.c
示例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;
}
开发者ID:bobzhang,项目名称:ocaml,代码行数:9,代码来源:io.c
示例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);
}
开发者ID:acekiller,项目名称:imageflow,代码行数:9,代码来源:corefoundation.c
示例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;
}
开发者ID:gndl,项目名称:ocaml-gstreamer,代码行数:10,代码来源:gstreamer_stubs.c
示例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;
}
开发者ID:gndl,项目名称:ocaml-gstreamer,代码行数:10,代码来源:gstreamer_stubs.c
示例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;
}
开发者ID:gndl,项目名称:ocaml-gstreamer,代码行数:10,代码来源:gstreamer_stubs.c
示例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;
}
开发者ID:KTXSoftware,项目名称:ocamllibs,代码行数:18,代码来源:extc_stubs.c
示例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;
}
开发者ID:gndl,项目名称:ocaml-gstreamer,代码行数:11,代码来源:gstreamer_stubs.c
示例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);
}
开发者ID:eras,项目名称:webcamviewer,代码行数:54,代码来源:ffmpeg-stubs.c
示例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);
}
开发者ID:Feechka,项目名称:UOBP,代码行数:11,代码来源:brlapi_stubs.c
示例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);
}
开发者ID:braibant,项目名称:ocaml-ctypes,代码行数:12,代码来源:managed_buffer_stubs.c
示例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);
}
开发者ID:forhappy,项目名称:uv-ocaml,代码行数:12,代码来源:camluv_check.c
示例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);
}
开发者ID:forhappy,项目名称:uv-ocaml,代码行数:12,代码来源:camluv_handle.c
示例16: Val_guestfs
static value
Val_guestfs (guestfs_h *g)
{
CAMLparam0 ();
CAMLlocal1 (rv);
rv = caml_alloc_custom (&guestfs_custom_operations,
sizeof (guestfs_h *), 0, 1);
Guestfs_val (rv) = g;
CAMLreturn (rv);
}
开发者ID:gaowanlong,项目名称:libguestfs,代码行数:12,代码来源:guestfs_c.c
示例17: camluv_copy_key
static value
camluv_copy_key(camluv_key_t *camluv_key)
{
CAMLparam0();
CAMLlocal1(key);
key = caml_alloc_custom(&camluv_key_struct_ops,
sizeof(camluv_key_t *), 0, 1);
camluv_key_struct_val(key) = camluv_key;
CAMLreturn(key);
}
开发者ID:forhappy,项目名称:uv-ocaml,代码行数:12,代码来源:camluv_key.c
示例18: sankoff_CAML_filter_character
value
sankoff_CAML_filter_character(value this_eltarr, value ecode_bigarr, value get_comp) {
CAMLparam3(this_eltarr,ecode_bigarr,get_comp);
CAMLlocal1(res);
int get_complementary = Int_val(get_comp);
int * ecode_arr = (int*) Data_bigarray_val(ecode_bigarr);
eltarr_p eap;
Sankoff_eltarr_custom_val(eap,this_eltarr);
int num_elts=eap->num_elts;
int res_num_elts=0;//must init to 0
int i;
elt_p ep;
int * sign_arr = (int*)calloc(num_elts,sizeof(int));
for (i=0;i<num_elts;i++) {
ep = &((eap->elts)[i]);
if(get_complementary) {
if( int_array_is_mem(ecode_arr,num_elts,ep->ecode) )
{ sign_arr[i]=0; }
else { sign_arr[i]=1; res_num_elts++; }
}
else {
if( int_array_is_mem(ecode_arr,num_elts,ep->ecode) )
{ sign_arr[i]=1; res_num_elts++; }
else sign_arr[i]=0;
}
}
eltarr_p res_eap;
res_eap = (eltarr_p)calloc(1,sizeof(struct elt_arr));
int num_states = eap->num_states;
res_eap->code = eap->code;
res_eap->num_states = eap->num_states;
res_eap->num_elts = res_num_elts;
res_eap->tcm = (int*)calloc(num_states*num_states,sizeof(int));
res_eap->is_identity = eap->is_identity;
memcpy (res_eap->tcm,eap->tcm,sizeof(int)*num_states*num_states);
res_eap->elts = (elt_p)calloc(res_num_elts,sizeof(struct elt));
elt_p res_elts = res_eap->elts;
int j=0;
for (i=0;i<num_elts;i++) {
if(sign_arr[i]==1) {
sankoff_create_empty_elt(&(res_elts[j]),num_states,-1);
sankoff_clone_elt(&(res_elts[j]),&((eap->elts)[i]));
j++;
}
}
free(sign_arr);
assert(j==res_num_elts);
res = caml_alloc_custom(&sankoff_custom_operations_eltarr,sizeof(eltarr_p),1,alloc_custom_max);
Sankoff_return_eltarr(res) = res_eap;
CAMLreturn(res);
}
开发者ID:amnh,项目名称:poy5,代码行数:52,代码来源:sankoff.c
示例19: caml_create_texture
// INPUT nothing
// OUTPUT a fresh texture id
CAMLprim value
caml_create_texture(value unit)
{
CAMLparam0();
CAMLlocal1(v);
GLuint buf[1];
glGenTextures(1, buf);
v = caml_alloc_custom( &tex_custom_ops, sizeof(GLuint), 0, 1);
memcpy( Data_custom_val(v), buf, sizeof(GLuint) );
CAMLreturn(v);
}
开发者ID:ogaml,项目名称:ogaml,代码行数:15,代码来源:texture_stubs.c
示例20: caml_zmq_copy_socket
/* Captures a reference to the context to avoid collecting it prematurely */
value caml_zmq_copy_socket(value context, void *zmq_socket) {
CAMLparam0 ();
CAMLlocal2 (socket, tuple);
socket = caml_alloc_custom(&caml_zmq_socket_ops, sizeof (zmq_socket), 0, 1);
CAML_ZMQ_Socket_inner_val(socket) = zmq_socket;
tuple = caml_alloc_tuple(2);
Field(tuple, 0) = context;
Field(tuple, 1) = socket;
CAMLreturn (tuple);
}
开发者ID:gdsfh,项目名称:ocaml-zmq,代码行数:14,代码来源:socket.c
注:本文中的caml_alloc_custom函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论