Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Thread Tools Display Modes
Old 12-24-2021, 05:00 AM   #1
Human being with feelings
Join Date: Jul 2009
Posts: 3,628
Default Extension API: in parameter pair "char* buf" "int buf_sz", size is incorrect

If an extension registers a function with a pair of parameters named "const char* something" and "int something_sz", REAPER recognizes these parameters as a linked pair. The script only has to supply the char* argument, and REAPER itself supplies the value of something_sz.

However, the value that REAPER supplies doesn't seem to be correct or useful. It seems to be calculated as one less than the number of characters before the first \0 char (unless \0 is the first character, in which case it is calculated differently).

It would be much more useful if REAPER passes the exact char length of the string (including all internal and terminal \0 chars). This would allow the extension to read the entire string without fears of memory access violations.

At present, in order for the extension to know the true length of a string argument, the script/user has to supply the length as a separate argument.
juliansader is offline   Reply With Quote
Old 12-24-2021, 05:10 AM   #2
schwa's Avatar
Join Date: Mar 2007
Location: NY
Posts: 12,420

A string in many languages including C/C++ (but not Lua) is just a pointer to a string of characters, with no intrinsic length information. The standard C strlen function simply counts characters until the first 0 is seen. If a string contains more information beyond the first 0 character, that has to be specified by whoever created the string, there's no way for the receiver to know.
schwa is offline   Reply With Quote
Old 12-24-2021, 06:18 AM   #3
Human being with feelings
nofish's Avatar
Join Date: Oct 2007
Location: home is where the heart is
Posts: 10,971

This helps maybe?

Sorry, that's about out parameters, not in parameters.

Last edited by nofish; 12-24-2021 at 06:28 AM.
nofish is offline   Reply With Quote
Old 12-25-2021, 12:31 PM   #4
Justin's Avatar
Join Date: Jan 2005
Location: NYC
Posts: 13,919

Edit: ah yes, there's some bugs in this, fixing!

Last edited by Justin; 12-25-2021 at 12:39 PM.
Justin is online now   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 07:27 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.