# Idiomatic Racket CS replacement for \`scheme\_malloc\_code\`?

**URL:** <https://racket.discourse.group/t/idiomatic-racket-cs-replacement-for-scheme-malloc-code/4114>\
**Category:** General\
**Created:** [February 18, 2026, 10:32am UTC](https://racket.discourse.group/t/idiomatic-racket-cs-replacement-for-scheme-malloc-code/4114 "2026-02-18T10:32:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyg](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/tonyg/32/562_2.png) [@tonyg](https://racket.discourse.group/u/tonyg)\
**Post date:** [February 18, 2026, 10:32am UTC](https://racket.discourse.group/t/idiomatic-racket-cs-replacement-for-scheme-malloc-code/4114/1 "2026-02-18T10:32:31Z")

</div>

Hi all,

I'm looking for the best idiomatic replacement for `scheme_malloc_code` in Racket CS.

Previously, I could run:

```racket
(define builtins (ffi-lib #f))
(define %scheme-malloc-code
  (get-ffi-obj "scheme_malloc_code" builtins (_fun (size : _long) -> (_bytes o size))))

```

... and use `%scheme-malloc-code` to get a callable, writable bytevector for sticking machine code in, plus the GC would clean it up if it became reclaimable.

Are there any (even rough) equivalents in Racket CS?

Best,  
Tony
