Skip to content

Commit

Permalink
Example compliance in SDK for Memory::set() usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed May 21, 2024
1 parent 8856159 commit f02a4a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions examples/sdk/fileex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ void read_file();
void delete_file();

i32 main() {
Memory::initialize();

create_file();
read_file();
delete_file();
Expand All @@ -42,9 +44,7 @@ void create_file() {

void read_file() {
File file = File::open(F("/test.txt"), F("r"));

string contents;
Memory::set(contents, 0, file.size() + 1);
string contents = (string) Memory::alloc(file.size() + 1);

IO::print(F("Reading from file: "));
IO::print(file.name());
Expand All @@ -60,6 +60,8 @@ void read_file() {
IO::print(F("Contents: "));
IO::print(contents);
IO::print(F("\r\n"));

Memory::free(contents);
}

void delete_file() {
Expand Down
2 changes: 1 addition & 1 deletion examples/sdk/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <librishka.h>

i32 main() {
i32 exitcode = Sys::shellexec(F("/hello.bin"), 0, (char**) nil);
i32 exitcode = Sys::shellexec(F("/hello.bin"));

IO::print(F("Exit code: "));
IO::print((i64) exitcode);
Expand Down

0 comments on commit f02a4a8

Please sign in to comment.