Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Pb "interface C <-> Ocaml" with array of string
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-03-22 (15:33)
From: Frédéric_Gava <gava@u...>
Subject: Pb "interface C <-> Ocaml" with array of string
Dear Caml-List,

I have a problem with an initialization of a array of strings using a C
procedure. I give you the code
with some comments. My code works well without threads but when I add  some
threads to my code the array is initializing with some strange strings. If
someone could help me...

Frédéric Gava

char **argv;

/* "arguments" is the Ocaml Sys.argv array */
value bsmlpub_init(value arguments)
  int argc,i;
  /* alloc the arguments */
  argc = Wosize_val(arguments);
  argv = (char**)stat_alloc((argc + 1) * sizeof(char *));
  for (i = 0; i < argc; i++) argv[i] = String_val(Field(arguments, i));
  argv[i] = NULL;
  /* saving them */
 /* This function is a C function take from a special library for parallel
computing. So it is impossible to modified this function. This function
gives to all processors the same parameters take from the line command of
the bash. */
  bsplib_saveargs(&argc, &argv);
  CAMLreturn (Val_unit);

/* Them, when a program wants to read the parameters, it calls this
functions, but here
I have an array with bad strings.... */
value bsmlpub_argv(value unit)
 CAMLreturn (copy_string_array(argv));