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:

alloc_surf_data_ptr doesn't work for trim_type


Recommended Posts

The first time alloc_surf_data_ptr is called, it does not allocate memory and the pointers remain null.

The problem is ONLY for TRIM_SURF. No problem with other surface types.

If I repeat the call with the same parameters then the memory is allocated:

	// Make TrimSurf
	ent eTrimSurf;
	memset (&eTrimSurf, 0, sizeof (ent));

	surf_type& sTrimSurf = eTrimSurf.u.sf;
	sTrimSurf.s.type = TRIM_SURF;
	eTrimSurf.refs = 0;	

	// Fill in general trim surf stuff and allocate space for trim surf data...
	trim_type& trim = sTrimSurf.u.trim;

	trim.psf = pParentSurface;
	trim.outer_trimmed = false;
	trim.n_pts = 0;

	trim.c_ptr = nullptr;
	alloc_surf_data_ptr (&sTrimSurf);

	// TODO: alloc_surf_data_ptr does nothing the first time it is called
	if (trim.c_ptr == nullptr)
	{
		alloc_surf_data_ptr (&sTrimSurf);
	}
	ASSERT (trim.c_ptr != nullptr);

	if (trim.c_ptr == nullptr)
		return nullptr;

This seems like an easy workaround and in most cases it works, but there are cases where the memory is corrupted and an invalid object is written to the database and/or there is a memory leak at the end.

I think this is a bug in the chooks SDK. I'm using 2024, haven't tried 2025 yet.
Has anyone else run into this problem and have a better solution?

 

 

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...