Re: Passing NULL to a c function
- Posted by Mark Brown <mabrown at SENET.COM.AU> Mar 15, 2000
- 627 views
------=_NextPart_000_0021_01BF8EB1.90C8D660 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi All. Regarding the NULL pointer problem I've solved it this way. global function Morfit_engine_load_world( sequence world_file_name, = sequence world_directory_path, sequence bitmaps_directory_path, atom = world_mode) -- int Morfit_engine_load_world(char *world_file_name, char = *world_directory_path, char *bitmaps_directory_path, int world_mode) atom world_file_name_ptr, world_directory_path_ptr, bitmaps_directory_path_ptr if length(world_file_name) !=3D 0 then world_file_name_ptr =3D allocate_string(world_file_name) else -- zero length sequence world_file_name_ptr =3D NULL end if if length(world_directory_path) !=3D 0 then world_directory_path_ptr =3D = allocate_string(world_directory_path) else -- zero length sequence world_directory_path_ptr =3D NULL end if if length(bitmaps_directory_path) !=3D 0 then bitmaps_directory_path_ptr =3D = allocate_string(bitmaps_directory_path) else -- zero length sequence bitmaps_directory_path_ptr =3D NULL end if return c_func(xMorfit_engine_load_world,{ world_file_name_ptr, = world_directory_path_ptr, bitmaps_directory_path_ptr, world_mode} ) end function The above works but if anyone can think of a better/neater way I'd be = pleased to see it. Cheers Mark ------=_NextPart_000_0021_01BF8EB1.90C8D660 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT size=3D2>Hi All.</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2>Regarding the NULL pointer problem I've solved it = this=20 way.</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2>global function Morfit_engine_load_world( sequence=20 world_file_name, sequence world_directory_path, sequence = bitmaps_directory_path,=20 atom world_mode)<BR> -- int = Morfit_engine_load_world(char=20 *world_file_name, char *world_directory_path, char = *bitmaps_directory_path, int=20 world_mode)<BR> atom=20 world_file_name_ptr,<BR> = bsp;=20 bitmaps_directory_path_ptr</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2> if length(world_file_name) !=3D 0 = then<BR> world_file_name_ptr = =3D=20 else<BR> -- zero length=20 sequence<BR> = world_file_name_ptr =3D=20 NULL<BR> end if</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2> if length(world_directory_path) = !=3D 0=20 then<BR> = world_directory_path_ptr =3D=20 else<BR> -- zero length=20 sequence<BR> = world_directory_path_ptr=20 =3D NULL<BR> end if</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2> if length(bitmaps_directory_path) = !=3D 0=20 then<BR> = bitmaps_directory_path_ptr =3D=20 else<BR> -- zero length=20 bitmaps_directory_path_ptr =3D NULL<BR> end = if</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2> return = c_func(xMorfit_engine_load_world,{=20 world_file_name_ptr, world_directory_path_ptr, = bitmaps_directory_path_ptr,=20 world_mode} )<BR>end function</FONT></DIV> <DIV> </DIV> <DIV> </DIV> <DIV><FONT size=3D2>The above works but if anyone can think of a = better/neater way=20 I'd be pleased to see it.</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2>Cheers</FONT></DIV> <DIV> </DIV> ------=_NextPart_000_0021_01BF8EB1.90C8D660--