What I would welcome is some education regarding the poking and peeking etc going on. I know what poke and peek mean, but I'm only using them by copying you, not because I know what I'm doing
The 'AllocateMemory' eventproc is used because the fc2f3fd5 function that returns the name expects pointers to put the length value and the address of the name string in, and Lua doesn't have a native way to pass pointers.
8 bytes because it needs two 32 bit values. ppname is set to the first, plen to the second.
The initial poke just sets each to 0, mostly to be able to tell if the function actually changed the value.
After the call, the values are read out using peek. len is the actual length value, while pname is the address of the start of the string.
CHDK Lua doesn't have a way to directly get a C string from memory into a lua string, so the while loop reads it out byte by byte. Since I wasn't sure how the function actually worked, it checks for both the returned length and a possible terminating null. The Canon code uses a printf-like function, so it should be pretty safe to assume the name is null terminated, but I wanted to be sure it stopped fairly quickly even if I misunderstood the function.
Other notes:
In
local status=call_func_ptr(get_lens_name_fn,ppname,plen)
status was another thing I put in just in case I didn't understand the function, you shouldn't need it.
I would suggest keeping status checks for event proc calls like
if ppname == -1 or ppname == 0 then
error('AllocateMemory failed')
end
When everything is working normally they are harmless, and if something isn't it will be a lot easier to see the error than debug a crash.