caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christopher Quinn <cq@htec.demon.co.uk>
To: Berke Durak <berke@altern.org>
Cc: caml-list@inria.fr
Subject: [Caml-list] Re: Some suggested improvements to the Graphics and Bigarray modules
Date: Wed, 10 Oct 2001 00:21:09 +0100	[thread overview]
Message-ID: <3BC38665.5F0A6729@htec.demon.co.uk> (raw)
In-Reply-To: <20011009233142.A10140@gogol.zorgol>

>  As a palliative a function for
> inter-converting portions of Bigarrays and strings would be welcome,
> as access to strings is much faster.
> 

If you don't mind giving up a bit of safety the following may help. 

Chris Q.

module UnsafeStringOps = struct
  (* Warning: No bounds checking!!!! Coredump grade hack *)

  let ba2str : ('a,'b,'c) Bigarray.Array1.t -> string =
    fun arr -> Obj.obj (Obj.field (Obj.repr arr) 1)

(* Or more properly:
external ba2str: ('a,'b,'c) Bigarray.Array1.t -> string ="ba2str"

where from C you put:
#include <bigarray.h>
value ba2str(value arr){ return Data_bigarray_val(arr); }
*)

  let blit = String.unsafe_blit
  let fill = String.unsafe_fill
  let set = String.unsafe_set
  let get = String.unsafe_get
end
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-10-09 23:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-09 21:31 [Caml-list] " Berke Durak
2001-10-09 23:21 ` Christopher Quinn [this message]
2001-10-10  0:52 ` Jeff Henrikson
2001-10-10  7:04   ` Chris Hecker
2001-10-10 19:47     ` Jeff Henrikson
2001-10-11  0:50       ` John Prevost
2001-10-12 14:29 ` Jun P. FURUSE
2001-10-12 15:02 ` Xavier Leroy
2001-10-12 15:38   ` Berke Durak
2001-10-12 17:15     ` Daniel de Rauglaudre
2001-10-13 23:16       ` Berke Durak
2001-10-14  3:14         ` Daniel de Rauglaudre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3BC38665.5F0A6729@htec.demon.co.uk \
    --to=cq@htec.demon.co.uk \
    --cc=berke@altern.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).