Browse Source

Add `strings.ptr_from_string`

gingerBill 5 years ago
parent
commit
6b5ea011e7
2 changed files with 5 additions and 1 deletions
  1. 1 1
      build.bat
  2. 4 0
      core/strings/strings.odin

+ 1 - 1
build.bat

@@ -41,7 +41,7 @@ del *.ilk > NUL 2> NUL
 
 cl %compiler_settings% "src\main.cpp" ^
 	/link %linker_settings% -OUT:%exe_name% ^
-	&& odin run examples/demo/demo.odin
+	&& odin build examples/demo/demo.odin -keep-temp-files
 
 del *.obj > NUL 2> NUL
 

+ 4 - 0
core/strings/strings.odin

@@ -42,6 +42,10 @@ string_from_ptr :: proc(ptr: ^byte, len: int) -> string {
 	return transmute(string)mem.Raw_String{ptr, len};
 }
 
+ptr_from_string :: proc(str: string) -> ^byte {
+	d := transmute(mem.Raw_String)str;
+	return d.data;
+}
 
 unsafe_string_to_cstring :: proc(str: string) -> cstring {
 	d := transmute(mem.Raw_String)str;