You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/06/19 05:26:01 UTC

[incubator-opendal] 01/01: fix: Fix the build for zig binding

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch try-fix-zig
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit b0c19f5fd795f9600e5bb1b91df1f7e135f5c313
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Mon Jun 19 13:25:47 2023 +0800

    fix: Fix the build for zig binding
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 bindings/zig/test/bdd.zig | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/bindings/zig/test/bdd.zig b/bindings/zig/test/bdd.zig
index 04451f784..08772f1e5 100644
--- a/bindings/zig/test/bdd.zig
+++ b/bindings/zig/test/bdd.zig
@@ -24,7 +24,7 @@ test "Opendal BDD test" {
     const c_str = [*:0]const u8; // define a type for 'const char*' in C
 
     const OpendalBDDTest = struct {
-        p: opendal.c.opendal_operator_ptr,
+        p: [*c]const opendal.c.opendal_operator_ptr,
         scheme: c_str,
         path: c_str,
         content: c_str,
@@ -35,19 +35,18 @@ test "Opendal BDD test" {
             self.path = "test";
             self.content = "Hello, World!";
 
-            var options: opendal.c.opendal_operator_options = opendal.c.opendal_operator_options_new();
-            defer opendal.c.opendal_operator_options_free(&options);
-            opendal.c.opendal_operator_options_set(&options, "root", "/myroot");
+            var options: [*c] opendal.c.opendal_operator_options = opendal.c.opendal_operator_options_new();
+            defer opendal.c.opendal_operator_options_free(options);
+            opendal.c.opendal_operator_options_set(options, "root", "/myroot");
 
             // Given A new OpenDAL Blocking Operator
-            self.p = opendal.c.opendal_operator_new(self.scheme, &options);
-            std.debug.assert(self.p.ptr != null);
+            self.p = opendal.c.opendal_operator_new(self.scheme, options);
 
             return self;
         }
 
         pub fn deinit(self: *Self) void {
-            opendal.c.opendal_operator_free(&self.p);
+            opendal.c.opendal_operator_free(self.p);
         }
 
         const Self = @This();
@@ -73,12 +72,12 @@ test "Opendal BDD test" {
     // The blocking file "test" entry mode must be file
     var s: opendal.c.opendal_result_stat = opendal.c.opendal_operator_stat(testkit.p, testkit.path);
     try testing.expectEqual(s.code, @enumToInt(Code.OK));
-    var meta: opendal.c.opendal_metadata = s.meta;
-    try testing.expect(opendal.c.opendal_metadata_is_file(&meta));
+    var meta: [*c]const opendal.c.opendal_metadata = s.meta;
+    try testing.expect(opendal.c.opendal_metadata_is_file(meta));
 
     // The blocking file "test" content length must be 13
-    try testing.expectEqual(opendal.c.opendal_metadata_content_length(&meta), 13);
-    defer opendal.c.opendal_metadata_free(&meta);
+    try testing.expectEqual(opendal.c.opendal_metadata_content_length(meta), 13);
+    defer opendal.c.opendal_metadata_free(meta);
 
     // The blocking file "test" must have content "Hello, World!"
     var r: opendal.c.opendal_result_read = opendal.c.opendal_operator_blocking_read(testkit.p, testkit.path);