Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

select_ents memory question


Recommended Posts

While I have not used the function, I would say it simply returns pointers to elements from Mastercam's own database and no explicit freeing is expected from the caller.

 

But the function is either under-documented or dangerous. How does it know how big is your array it is supposed to fill? I think that *num_eptrs should be prefilled with the array size before the call, and the function will update it to reflect the number of elements store. That was the "under-documented" scenario from the above. The worse scenario is that it just stores as many entity pointers as needed, and you better provide a humongous array if you want to be safe!

Link to comment
Share on other sites

Bryan,

 

It’s been awhile since we’ve heard from you!

 

quote:

Does anybody know if when using the eptrs and num_eptrs parameters in select_ents is the user responsible for freeing up the memory or does Mastercam clean it up later by itself?

eptrs -- you do want to free.

 

if (eptrs != NULL) { free(eptrs); }

 

num_eptrs -- is just an int, so there would be no need to do a free on it.

 

Markov,

quote:

I think that *num_eptrs should be prefilled with the array size before the call, and the function will update it to reflect the number of elements store.

What would be the purpose of this?!?

“Prefilling” the count of something that you have no idea how many will be found would just be a unnecessary step.

Link to comment
Share on other sites

Hi Roger,

 

I've been hiding under a rock for awhile. Buried under a lot of other projects. I'm trying to get back to some chook bugs, upgrades, new chook requests here at the shop.

 

Thanks for the info. It just occurred to me while using the function there wasn't explicit "you need to clean this up yourself" comment in the doc and I was afraid of a memory leak. Or worse freeing it myself only to have MC do it later and crash. frown.gif

 

Bryan smile.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...