diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2015-02-06 15:54:05 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2015-02-06 15:54:05 +0000 |
commit | 11bc5fe4bf05081ec7da05a6d407d39ceba727a4 (patch) | |
tree | ff913eea8d116e337dc209afb54e975072ec7325 /byterun/caml/memory.h | |
parent | c38fc546dcddd768f0affd645c8c526b0df254f4 (diff) |
GPR#142: add a CAMLdrop macro for undoing CAMLparam*/CAMLlocal*
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15814 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/caml/memory.h')
-rw-r--r-- | byterun/caml/memory.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/byterun/caml/memory.h b/byterun/caml/memory.h index 2aa9c74eb..98a30cc1b 100644 --- a/byterun/caml/memory.h +++ b/byterun/caml/memory.h @@ -154,7 +154,9 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ Your function may raise an exception or return a [value] with the [CAMLreturn] macro. Its argument is simply the [value] returned by your function. Do NOT directly return a [value] with the [return] - keyword. If your function returns void, use [CAMLreturn0]. + keyword. If your function returns void, use [CAMLreturn0]. If you + un-register the local roots (i.e. undo the effects of the [CAMLparam*] + and [CAMLlocal] macros) without returning immediately, use [CAMLdrop]. All the identifiers beginning with "caml__" are reserved by OCaml. Do not use them for anything (local or global variables, struct or @@ -294,15 +296,17 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ CAMLxparamN (x, (size)) +#define CAMLdrop caml_local_roots = caml__frame + #define CAMLreturn0 do{ \ - caml_local_roots = caml__frame; \ + CAMLdrop; \ return; \ }while (0) #define CAMLreturnT(type, result) do{ \ type caml__temp_result = (result); \ - caml_local_roots = caml__frame; \ - return (caml__temp_result); \ + CAMLdrop; \ + return caml__temp_result; \ }while(0) #define CAMLreturn(result) CAMLreturnT(value, result) |