Hi Andy, Thanks for looking into this.
Looking at the kinematics modules I suspect malloc can only be used in user space modules. For example genserkins.c seems to use hal_malloc if RTAPI is defined and malloc if ULAPI is defined. I also see references to rtapi_kmalloc. hm2 seems to be especially keen on this method.
Looking at https://github.com/LinuxCNC/linuxcnc/blob/master/src/rtapi/rtapi_slab.h rtapi_kmalloc is defined as kmalloc for RTAPI and malloc for ULAPI, which again hints that RTAPI can't handle malloc. I should be able to work with rtapi_kmalloc.
Les On 14/08/2019 15:59, andy pugh wrote:
As I understand it, hal_malloc is meant for allocating shared memory. If your module does not need to share data then I think that conventional malloc can be used. However I don't see much evidence that it is in any hal components, but it is in some of the hal drivers. (I don't have access to a Linuxcnc repository at the moment other than github, and that has the worst search in the world, so I can't easily check properly). hal_malloc itself has a comment: https://github.com/LinuxCNC/linuxcnc/blob/1db55cf2187a654e378f771050ac5e825533e316/src/hal/hal.h#L192 During EXTRA_SETUP you can use extra_arg to get the instance index being processed. It may be that extra_arg is also passed to EXTRA_CLEANUP for the same reason.
_______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers