On Wed, 14 Aug 2019 at 15:08, Les Newell <les.new...@fastmail.co.uk> wrote:

> I am working on a hal module that may need a variable amount of memory
> depending on it's configuration. Is it acceptable to use malloc in a hal
> module? Should I use hal_malloc or is that specifically for pins?


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.


-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is designed
for the especial use of mechanical geniuses, daredevils and lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1916

_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to