caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] help with caml_stat_alloc
@ 2006-07-24  7:50 Jonathan Roewen
  2006-07-24  8:56 ` Richard Jones
  2006-07-24 11:39 ` Anatoly Zaretsky
  0 siblings, 2 replies; 4+ messages in thread
From: Jonathan Roewen @ 2006-07-24  7:50 UTC (permalink / raw)
  To: caml-list

Hi,

I'm trying to allocate some memory outside of the caml heap, and I 
think caml_stat_alloc is the right function to use. Anyways, it's 
generating seg-faults, so I'm hoping someone can help me fix my 
implementation.

CAMLprim value icfp_alloc(value size) {
	int sz = Int32_val(size) + 1;
	int *p = (int *)caml_stat_alloc(sz);
	p[--sz] = sz;
	/*while ( sz > 0 ) {
		p[--sz] = 0;
	}*/
	return caml_copy_int32(p);
}

Also, my interface in ocaml is:

external alloc : int32 -> int32 = "icfp_alloc"
external free : int32 -> unit = "icfp_free"
external get : int32 -> int32 -> int32 = "icfp_get"
external set : int32 -> int32 -> int32 -> unit = "icfp_set"
external copy : int32 -> int32 = "icfp_copy"

Some guidance would be much appreciated,

Jonathan


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-24 11:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-24  7:50 [Caml-list] help with caml_stat_alloc Jonathan Roewen
2006-07-24  8:56 ` Richard Jones
2006-07-24 10:13   ` Olivier Andrieu
2006-07-24 11:39 ` Anatoly Zaretsky

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).