Anonymous user
Call a function in a shared library/OCaml: Difference between revisions
Call a function in a shared library/OCaml (view source)
Revision as of 20:40, 17 May 2010
, 14 years agofixed correctly free when failure
mNo edit summary |
m (fixed correctly free when failure) |
||
Line 126:
ffi_status status;
ffi_type *rtype;
int ffi_prep_cif_failed = 0;
nargs = Wosize_val(ml_args);
Line 210 ⟶ 211:
status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, nargs, rtype, arg_types);
if (status != FFI_OK) {
ffi_prep_cif_failed = 1;
goto freeandfail;
failwith("ffi_prep_cif");▼
}
Line 246 ⟶ 244:
}
freeandfail:
for (i = 0; i < nargs; i++) {
switch (Tag_val(Field(ml_args, i))) {
Line 275 ⟶ 274:
free(arg_values);
free(arg_types);
if (ffi_prep_cif_failed)
▲ failwith("ffi_prep_cif");
CAMLreturn(ml_ret);
Line 286 ⟶ 288:
Here is the '''"Makefile"''':
<lang make>FFI_LIBS := $(shell pkg-config --libs libffi)▼
▲FFI_LIBS := $(shell pkg-config --libs libffi)
FFI_CFLAGS := $(shell pkg-config --cflags libffi)
|