601 #endif
602
603 #endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
604
605 /* Allocate a chunk of memory with the given size. Returns a pointer
606 to the writable address, and sets *CODE to the executable
607 corresponding virtual address. */
608 void *
609 ffi_closure_alloc (size_t size, void **code)
610 {
611 void *ptr;
612
613 if (!code)
614 return NULL;
615
616 ptr = dlmalloc (size);
617
618 if (ptr)
619 {
620 msegmentptr seg = segment_holding (gm, ptr);
621
622 *code = add_segment_exec_offset (ptr, seg);
623 }
624
625 return ptr;
626 }
627
628 /* Release a chunk of memory allocated with ffi_closure_alloc. If
629 FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
630 writable or the executable address given. Otherwise, only the
631 writable address can be provided here. */
632 void
633 ffi_closure_free (void *ptr)
634 {
635 #if FFI_CLOSURE_FREE_CODE
636 msegmentptr seg = segment_holding_code (gm, ptr);
637
638 if (seg)
639 ptr = sub_segment_exec_offset (ptr, seg);
640 #endif
|
601 #endif
602
603 #endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
604
605 /* Allocate a chunk of memory with the given size. Returns a pointer
606 to the writable address, and sets *CODE to the executable
607 corresponding virtual address. */
608 void *
609 ffi_closure_alloc (size_t size, void **code)
610 {
611 void *ptr;
612
613 if (!code)
614 return NULL;
615
616 ptr = dlmalloc (size);
617
618 if (ptr)
619 {
620 msegmentptr seg = segment_holding (gm, ptr);
621 #ifdef GSTREAMER_LITE
622 if (seg == NULL)
623 return NULL;
624 #endif // GSTREAMER_LITE
625
626 *code = add_segment_exec_offset (ptr, seg);
627 }
628
629 return ptr;
630 }
631
632 /* Release a chunk of memory allocated with ffi_closure_alloc. If
633 FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
634 writable or the executable address given. Otherwise, only the
635 writable address can be provided here. */
636 void
637 ffi_closure_free (void *ptr)
638 {
639 #if FFI_CLOSURE_FREE_CODE
640 msegmentptr seg = segment_holding_code (gm, ptr);
641
642 if (seg)
643 ptr = sub_segment_exec_offset (ptr, seg);
644 #endif
|