Jump to content
Excelsior Forums
Sign in to follow this  
TPThompson

Argument(String, int, int) signature

Recommended Posts

you have any working examples of using this? sorry if i overlooked something in the samples.

I am specifically trying to work with this TidyLib function:

/** Save to given TidyBuffer object */

TIDY_EXPORT int         tidySaveBuffer( TidyDoc tdoc, TidyBuffer* buf );

and it seems that the signature (int*, int*) seems to work, and the dll actually objected to being passed a pointer to a Struct.

From docs:  This constructor should be used when it is required to pass a character buffer of a certain size as an argument, in particular, when it has to be passed to an output or input/output parameter.

Share this post


Link to post
Share on other sites

It seems there is no one in samples. The possible usage is as follows:

Suppose native C code that append some suffix to the received string:

void foo(char* str) {
  strcat(str, "_suffix");
}

In this case, passing the argument created by "new Argument(str, Argument.CSTRING)" is incorrect, as native function would damage the memory beyond the bounds of the allocated buffer. So, we need a way to allocate the buffer for the string of the arbitrary size. The way is using the constructor Argument(String, int, int):

Argument arg = new Argument(str, Argument.CSTRING, str.length() + 7);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×