search for: caml_raise_out_of_memory

Displaying 20 results from an estimated 69 matches for "caml_raise_out_of_memory".

2017 Mar 03
1
Re: [PATCH 08/11] ocaml: do not try to malloc 0 elements in get_all_event_callbacks
...+++ b/ocaml/guestfs-c.c > @@ -311,7 +311,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn) > } > > /* Copy them into the return array. */ > - r = malloc (sizeof (value *) * (*len_rtn)); > + r = malloc (sizeof (value *) * (*len_rtn + 1)); > if (r == NULL) caml_raise_out_of_memory (); Isn't it better to fix this by doing: r = malloc (sizeof (value *) * (*len_rtn)); - if (r == NULL) caml_raise_out_of_memory (); + if (*len_rtn > 0 && r == NULL) caml_raise_out_of_memory (); (same comment in the following patches) Rich. > > i = 0; > @@ -323...
2016 Feb 05
7
[PATCH 0/7] lib: Stop exporting the safe_malloc, etc. functions.
The safe_malloc (etc) functions call g->abort_fn on failure. That's not appropriate for language bindings, and we never intended that these internal functions be used from language bindings, that was just a historical accident. This patch series removes any external use of the safe_* functions. Rich.
2017 Sep 12
2
Re: [PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.
...if the Augeas.Error exception had all the available details, i.e. code, error message, minor message, and details. Right now it does not even include any of those, so it is hard for users to differentiate the error handling depending on the actual error. Also, IMHO failures related to ENOMEM should caml_raise_out_of_memory(). I guess this is not doable anymore, to avoid breaking the ocaml-augeas API? If it is doable, I'm willing to cook up a patch. -- Pino Toscano
2019 Aug 12
0
[PATCH libnbd 3/7] ocaml: Remove NBD.Buffer.free function, use a free callback instead.
...nce to the Buffer, so we\n"; + pr " * must treat it as a possible GC root.\n"; + pr " */\n"; + pr " value *%s_user_data;\n" n; + pr " %s_user_data = malloc (sizeof (value));\n" n; + pr " if (%s_user_data == NULL) caml_raise_out_of_memory ();\n" n; + pr " *%s_user_data = %sv;\n" n n; + pr " caml_register_generational_global_root (%s_user_data);\n" n; pr " struct nbd_buffer *%s_buf = NBD_buffer_val (%sv);\n" n n; pr " const void *%s = %s_buf->data;\n" n n...
2019 Aug 12
0
[PATCH libnbd 5/7] ocaml: Use free callback to free closure root, instead of valid_flag == FREE.
...pr " free_root (NULL, user_data);\n"; - pr "\n"; pr " return ret;\n"; pr "}\n"; pr "\n" @@ -5348,7 +5345,11 @@ let print_ocaml_binding (name, { args; optargs; ret }) = pr " if (%s_user_data == NULL) caml_raise_out_of_memory ();\n" cbname; pr " *%s_user_data = %sv;\n" cbname cbname; pr " caml_register_generational_global_root (%s_user_data);\n" cbname; - pr " const void *%s_callback = %s_%s_wrapper;\n" cbname name cbname + pr " const void *%s_callb...
2017 Mar 03
14
[PATCH 00/11] Various Coverity fixes
Hi, this patch series fixes some issues discovered by Coverity. Most of them are memory leaks, usually on error; there are also invalid memory access issues. Thanks, Pino Toscano (11): java: link libguestfs_jni against libutils java: fix invalid memory access for FBuffer in struct lists daemon: tsk: properly use GUESTFS_MAX_CHUNK_SIZE edit: fix small memory leak on error java: fix
2019 Aug 12
0
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...uffer pointer. The generated code for an OCaml persistent buffers eventually looks like this: /* The function may save a reference to the Buffer, so we * must treat it as a possible GC root. */ value *buf_user_data; buf_user_data = malloc (sizeof (value)); if (buf_user_data == NULL) caml_raise_out_of_memory (); *buf_user_data = bufv; caml_register_generational_global_root (buf_user_data); struct nbd_buffer *buf_buf = NBD_buffer_val (bufv); const void *buf = buf_buf->data; size_t count = buf_buf->len; if (nbd_add_free_callback (h, (void *)buf, free_root, b...
2019 Aug 14
4
[PATCH libnbd 0/2] Use free callback to dereference NBD.Buffer.
In this patch series we use the newly introduced free callback on the completion function to dererence the OCaml NBD.Buffer. I will make the same kind of change for Python later in a separate series. The completion function is always called at the C level, even if the OCaml program didn't use the optional argument. That's because the free callback doesn't run otherwise. There is a
2019 Aug 12
2
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
On 8/12/19 11:08 AM, Richard W.M. Jones wrote: > This adds a C-only semi-private function for freeing various types of > persistent data passed to libnbd. > > There are some similarities with nbd_add_close_callback which we > removed in commit 7f191b150b52ed50098976309a6af883d245fc56. > --- > +=head1 FREE CALLBACKS > + > +B<Note:> The API described in this
2017 Mar 03
0
[PATCH 08/11] ocaml: do not try to malloc 0 elements in get_all_event_callbacks
...ee3 100644 --- a/ocaml/guestfs-c.c +++ b/ocaml/guestfs-c.c @@ -311,7 +311,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn) } /* Copy them into the return array. */ - r = malloc (sizeof (value *) * (*len_rtn)); + r = malloc (sizeof (value *) * (*len_rtn + 1)); if (r == NULL) caml_raise_out_of_memory (); i = 0; @@ -323,6 +323,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn) } root = guestfs_next_private (g, &key); } + r[i] = NULL; return r; } -- 2.9.3
2017 Sep 12
0
Re: [PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.
...exception had all the > available details, i.e. code, error message, minor message, and details. > Right now it does not even include any of those, so it is hard for > users to differentiate the error handling depending on the actual error. > Also, IMHO failures related to ENOMEM should caml_raise_out_of_memory(). > > I guess this is not doable anymore, to avoid breaking the ocaml-augeas > API? If it is doable, I'm willing to cook up a patch. I'm not really fussed about that API. The only constraint is that this change would have to go into ocaml-augeas (ie. the upstream project) firs...
2019 Nov 26
0
[PATCH supermin] ext2: Build symbolic links correctly (RHBZ#1770304).
...irname, basename, - statbuf.st_mode, statbuf.st_uid, statbuf.st_gid, - statbuf.st_ctime, statbuf.st_atime, statbuf.st_mtime, - 0, 0, EXT2_FT_SYMLINK, &ino); - char *buf = malloc (statbuf.st_size+1); if (buf == NULL) caml_raise_out_of_memory (); @@ -797,7 +791,7 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest) if (r > statbuf.st_size) r = statbuf.st_size; buf[r] = '\0'; - ext2fs_symlink (data->fs, dir_ino, ino, dest, buf); + ext2fs_symlink (data->fs, dir_ino, 0, basen...
2019 Nov 29
0
[common PATCH 1/2] options: rename key.device as key.id
...57,8 @@ guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv) struct key_store_key key; elemv = Field (keysv, 0); - key.device = strdup (String_val (Field (elemv, 0))); - if (!key.device) + key.id = strdup (String_val (Field (elemv, 0))); + if (!key.id) caml_raise_out_of_memory (); v = Field (elemv, 1); diff --git a/options/key-option.pod b/options/key-option.pod index cc188dc..02dcf18 100644 --- a/options/key-option.pod +++ b/options/key-option.pod @@ -1,15 +1,16 @@ =item B<--key> SELECTOR Specify a key for LUKS, to automatically open a LUKS device when...
2019 Mar 22
0
[PATCH 3/4] common/mltools: allow fd for machine readable output
...,3 +107,16 @@ guestfs_int_mllib_set_keys_from_stdin (value unitv) keys_from_stdin = 1; return Val_unit; } + +value +guestfs_int_mllib_open_out_channel_from_fd (value fdv) +{ + CAMLparam1 (fdv); + struct channel *chan; + + chan = caml_open_descriptor_out (Int_val (fdv)); + if (!chan) + caml_raise_out_of_memory (); + + CAMLreturn (caml_alloc_channel (chan)); +} diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml index ade4cb37f..3c54cd4a0 100644 --- a/common/mltools/tools_utils.ml +++ b/common/mltools/tools_utils.ml @@ -32,6 +32,7 @@ and key_store_key = external c_inspect_decrypt...
2018 Aug 20
1
[PATCH] common/mltools: getopt: add Getopt.OptString
...tion -> unit) */ + has_arg = 2; + break; + default: error (EXIT_FAILURE, 0, "internal error: unhandled Tag_val (actionv) = %d", @@ -286,8 +290,11 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu caml_raise_out_of_memory (); optstring = newstring; optstring[optstring_len++] = key[0]; - if (has_arg) + if (has_arg > 0) { optstring[optstring_len++] = ':'; + if (has_arg > 1) + optstring[optstring_len++] = ':'; + } } else...
2019 Mar 29
0
[PATCH v2 1/3] common/mlpcre: add offset flag for PCRE.matches
..._pcre_matches (value offsetv, value rev, value strv) { - CAMLparam2 (rev, strv); + CAMLparam3 (offsetv, rev, strv); pcre *re = Regexp_val (rev); struct last_match *m, *oldm; size_t len = caml_string_length (strv); @@ -205,7 +214,8 @@ guestfs_int_pcre_matches (value rev, value strv) caml_raise_out_of_memory (); } - m->r = pcre_exec (re, NULL, m->subject, len, 0, 0, m->vec, veclen); + m->r = pcre_exec (re, NULL, m->subject, len, Optint_val (offsetv, 0), 0, + m->vec, veclen); if (m->r < 0 && m->r != PCRE_ERROR_NOMATCH) { int ret = m-&g...
2019 Aug 12
2
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...n OCaml persistent buffers eventually looks > like this: > > /* The function may save a reference to the Buffer, so we > * must treat it as a possible GC root. > */ > value *buf_user_data; > buf_user_data = malloc (sizeof (value)); > if (buf_user_data == NULL) caml_raise_out_of_memory (); > *buf_user_data = bufv; > caml_register_generational_global_root (buf_user_data); > struct nbd_buffer *buf_buf = NBD_buffer_val (bufv); > const void *buf = buf_buf->data; > size_t count = buf_buf->len; > if (nbd_add_free_callback (h, (void *)buf, >...
2019 Feb 25
0
[PATCH 1/3] common/mlpcre: add offset flag for PCRE.matches
..._pcre_matches (value offsetv, value rev, value strv) { - CAMLparam2 (rev, strv); + CAMLparam3 (offsetv, rev, strv); pcre *re = Regexp_val (rev); struct last_match *m, *oldm; size_t len = caml_string_length (strv); @@ -205,7 +214,8 @@ guestfs_int_pcre_matches (value rev, value strv) caml_raise_out_of_memory (); } - m->r = pcre_exec (re, NULL, m->subject, len, 0, 0, m->vec, veclen); + m->r = pcre_exec (re, NULL, m->subject, len, Optint_val (offsetv, 0), 0, + m->vec, veclen); if (m->r < 0 && m->r != PCRE_ERROR_NOMATCH) { int ret = m-&g...
2019 Dec 16
3
[v2v PATCH 0/2] Move libvirt-ocaml copy to v2v repo
libvirt-ocaml is used only by virt-v2v, so move it to this repository, instead of having it around in the common submodule. The removal from common will happen later. Pino Toscano (2): common: Bundle the libvirt-ocaml library for use by virt-v2v build: switch embedded copy of libvirt-ocaml .gitignore | 2 + 3rdparty/libvirt-ocaml/Makefile.am |
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
.../* The function may save a reference to the closure, so we\n"; pr " * must treat it as a possible GC root.\n"; pr " */\n"; - pr " %s_user_data = malloc (sizeof (value));\n" cbname; - pr " if (%s_user_data == NULL) caml_raise_out_of_memory ();\n" cbname; - pr " *%s_user_data = Field (%sv, 0);\n" cbname cbname; - pr " caml_register_generational_global_root (%s_user_data);\n" cbname; - pr " %s_callback = %s_wrapper;\n" cbname cbname; + pr " %s_callback.user_dat...