Re: Going About This Right
- Posted by ghaberek (admin) May 06, 2015
- 1429 views
petelomax said...
public constant xsfTexture_createFromFile = define_c_func(gfx,"sfTexture_createFromFile",{C_POINTER,C_POINTER},C_POINTER) public function sfTexture_createFromFile(sequence file,atom area) atom str,ret str = allocate_string(file) ret = c_func(xsfTexture_createFromFile,{str,area}) free(str) return ret end function
We can clean that up a bit by in-lining the call to allocate_string() with cleanup = 1. Without the call to free(), we can in-line the return value as well.
public constant xsfTexture_createFromFile = define_c_func(gfx,"sfTexture_createFromFile",{C_POINTER,C_POINTER},C_POINTER) public function sfTexture_createFromFile(sequence file,atom area = NULL) return c_func(xsfTexture_createFromFile,{allocate_string(file,1),area}) end function
Edit: apparently area can be NULL so let's add that as a default parameter.
-Greg