diff --git a/library/compiler/alien/malloc.factor b/library/compiler/alien/malloc.factor index b5564775a5..229e59a759 100644 --- a/library/compiler/alien/malloc.factor +++ b/library/compiler/alien/malloc.factor @@ -11,3 +11,7 @@ FUNCTION: void* realloc ( void* ptr, ulong size ) ; FUNCTION: void memcpy ( void* dst, void* src, ulong size ) ; : check-ptr [ "Out of memory" throw ] unless* ; + +: with-malloc ( size quot -- | quot: alien -- ) + swap 1 calloc dup check-ptr + [ swap call ] keep free ; inline diff --git a/library/ui/freetype/freetype-gl.factor b/library/ui/freetype/freetype-gl.factor index d60aca5846..8241d3cca2 100644 --- a/library/ui/freetype/freetype-gl.factor +++ b/library/ui/freetype/freetype-gl.factor @@ -117,9 +117,6 @@ C: font ( handle -- font ) load-glyph dup FT_RENDER_MODE_NORMAL FT_Render_Glyph freetype-error ; -: with-locked-block ( size quot -- | quot: address -- ) - swap 1 calloc [ alien-address swap call ] keep free ; inline - : copy-pixel ( bit tex -- bit tex ) 255 f pick set-alien-unsigned-1 1+ f pick alien-unsigned-1 @@ -145,8 +142,8 @@ C: font ( handle -- font ) #! Given a glyph bitmap, copy it to a texture with the given #! width/height (which must be powers of two). tuck sprite-size2 * 2 * [ - [ copy-bitmap ] keep gray-texture - ] with-locked-block ; + alien-address [ copy-bitmap ] keep gray-texture + ] with-malloc ; : glyph-texture-loc ( glyph font -- loc ) over glyph-hori-bearing-x ft-floor -rot