Showing results for 
Search instead for 
Did you mean: 
Flexera beginner

Free strings after flexnet API call.


I have a question about the string parameters that are passed to the Flexnet API, especially:

  • lc_checkout with the two parameters feature and version.
  • lc_set_attr with the parameter value when the key is LM_A_LICENSE_DEFAULT.

Is it safe to free these strings after the call ? I did not find any information, or I missed it, in the documentation.

Best regards.

0 Kudos
3 Replies
Flexera aparashar1

Re: Free strings after flexnet API call.

Hello @Aaylor ,

Post a checkout call (lc_checkout()), to return the licenses we would need to call a lc_checkin() which will need the feature name, so i would recommend you to not free it until then.

As a best practice, i would advise to free these at once when we are freeing the job handle, to ensure that we don't face any foreseen issues because of that.


0 Kudos
Flexera beginner

Re: Free strings after flexnet API call.

Hello @aparashar1,

Thanks for your answer.

My problem is that, we do not have the complete control of the memory, since we are working with a Garbage Collector (which may free the string, or move the string pointer).

To refine my question: do these functions (lc_checkout, ...) need the provided pointer to be valid during the job life (i.e. between a lc_checkout and a lc_checkin) ? Or is it safe to let the Garbage Collector to manage these strings.


Best regards,


0 Kudos
Flexera beginner

Re: Free strings after flexnet API call.

You should never have to keep your strings valid beyond the scope of the Flex API function calls you are making.  I have never done that and never had a problem with it.  I hope Flexera would never recommend keeping them in scope for the entire lifetime of the job.  If this were an actual requirement it should be listed in the API docs.

For two of the particular ones you mentioned, the feature and version, if you look in lmclient.h and look at the CONFIG struct, you can see that the feature and version are char buffers.  This suggests that your strings get copied to their buffers.  This should give you more confidence that your input strings can be freed or go out of scope after the lc_checkout calls.



0 Kudos