- CAMLparam2(file, load_bp);
- CAMLlocal1(result);
- Grammar *grammar;
- int f1 = Int_val(file);
- int f2 = dup(f1);
- FILE * fd = fdopen(f2, "r");
- if (fd == NULL)
- CAMLRAISEMSG("Error opening grammar file");
- grammar = Grammar::load(fd, Bool_val(load_bp));
- fclose(fd);
- result = sxsi_alloc_custom<Grammar*>();
- Obj_val<Grammar*>(result) = grammar;
- CAMLreturn(result);
+ CAMLparam1(size);
+ size_t bits = Long_val(size);
+ size_t words = bits / (8*sizeof(unsigned int));
+ unsigned int *buffer = (unsigned int*) calloc(words+1, sizeof(unsigned int));
+ if (buffer == NULL)
+ CAMLRAISEMSG("BP: cannot allocate memory");
+ CAMLreturn( (value) buffer);