Esempio n. 1
0
void payments_destroy() {
	if (successCb) {
		caml_remove_generational_global_root(&successCb);
		successCb = 0;
		caml_remove_generational_global_root(&errorCb);
		errorCb = 0;
	};
}
Esempio n. 2
0
static value result_read(struct job_read *job)
{
  value result;
  DWORD error = job->error_code;
  if (error) {
    caml_remove_generational_global_root(&job->string);
    lwt_unix_free_job(&job->job);
    win32_maperr(error);
    uerror("read", Nothing);
  }
  memcpy(String_val(job->string) + job->offset, job->buffer, job->result);
  result = Val_long(job->result);
  caml_remove_generational_global_root(&job->string);
  lwt_unix_free_job(&job->job);
  return result;
}
Esempio n. 3
0
/* Allocate handles and deal with finalization. */
static void
guestfs_finalize (value gv)
{
  guestfs_h *g = Guestfs_val (gv);

  if (g) {
    /* There is a nasty, difficult to solve case here where the
     * user deletes events in one of the callbacks that we are
     * about to invoke, resulting in a double-free.  XXX
     */
    size_t len, i;
    value **roots = get_all_event_callbacks (g, &len);

    /* Close the handle: this could invoke callbacks from the list
     * above, which is why we don't want to delete them before
     * closing the handle.
     */
    guestfs_close (g);

    /* Now unregister the global roots. */
    for (i = 0; i < len; ++i) {
      caml_remove_generational_global_root (roots[i]);
      free (roots[i]);
    }
    free (roots);
  }
}
static int callml_custom_free(SUNLinearSolver ls)
{
    caml_remove_generational_global_root((value *)&(ls->content));
    if (ls->ops != NULL) free(ls->ops);
    free(ls);

    return(SUNLS_SUCCESS);
}
Esempio n. 5
0
// Called by the host app to free a mitls_state allocated by FFI_mitls_configure()
void FFI_mitls_close(mitls_state *state)
{
    if (state) {
        caml_acquire_runtime_system();
        caml_remove_generational_global_root(&state->fstar_state);
        caml_release_runtime_system();
        state->fstar_state = 0;
        free(state);
    }
}
Esempio n. 6
0
static inline void np_decr_refcount(np_callback *c)
{
  if (c) {
    c->cnt--;
    if (c->cnt == 0) {
      caml_remove_generational_global_root(&c->v_cb);
      caml_stat_free(c);
    }
  }
}
Esempio n. 7
0
static inline void ref_count_finalize_dbw(db_wrap *dbw)
{
  if (--dbw->ref_count == 0) {
    user_function *link;
    for (link = dbw->user_functions; link != NULL; link = link->next) {
      caml_remove_generational_global_root(&link->v_fun);
      free(link);
    }
    dbw->user_functions = NULL;
    sqlite3_close(dbw->db);
    free(dbw);
  }
}
Esempio n. 8
0
static void
tcp_wrap_finalize(value v_tw)
{
    tcp_wrap *tw = Tcp_wrap_val(v_tw);
    LWIP_STUB_DPRINTF("tcp_wrap_finalize");
    if (tw->pcb) {
        if (tcp_close(tw->pcb) != ERR_OK)
            tcp_abort(tw->pcb);
        tw->pcb = NULL;
    }
    if (tw->desc->rx)
        pbuf_list_free(tw->desc->rx);
    if (tw->desc)
        free(tw->desc);
    if (tw->v)
        caml_remove_generational_global_root(&tw->v);
    free(tw);
}
Esempio n. 9
0
/* Guestfs.delete_event_callback */
value
ocaml_guestfs_delete_event_callback (value gv, value ehv)
{
  CAMLparam2 (gv, ehv);
  char key[64];
  int eh = Int_val (ehv);

  guestfs_h *g = Guestfs_val (gv);

  snprintf (key, sizeof key, "_ocaml_event_%d", eh);

  value *root = guestfs_get_private (g, key);
  if (root) {
    caml_remove_generational_global_root (root);
    free (root);
    guestfs_set_private (g, key, NULL);
    guestfs_delete_event_callback (g, eh);
  }

  CAMLreturn (Val_unit);
}
Esempio n. 10
0
static void caml_destroy_surface_callback(void *data)
{
  /* fprintf(stderr, "DESTROY surface callback\n");  fflush(stderr); */
  caml_remove_generational_global_root((value *)data);
  free(data);
}