-
-
Save haze/d7114588286456d7a34bff88328101e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn saveBodyToBuffer(argContent: *c_void, size: usize, nmemb: usize, userData: ?*c_void) callconv(.C) usize { | |
var buffer = @ptrCast(*std.Buffer, @alignCast(8, userData)); | |
var content: [*]u8 = @ptrCast([*]u8, blk: { | |
if (@alignOf(@TypeOf(argContent)) != 8) | |
break :blk @alignCast(8, argContent); | |
break :blk argContent; | |
}); | |
buffer.replaceContents(@ptrCast([*]u8, content)[0 .. size * nmemb]) catch { | |
std.debug.warn("summ bad happened\n", .{}); | |
return 0; | |
}; | |
return size * nmemb; | |
} | |
// this would give me errors | |
fn saveBodyToBuffer(argContent: *c_void, size: usize, nmemb: usize, userData: ?*c_void) callconv(.C) usize { | |
var buffer = @ptrCast(*std.Buffer, @alignCast(8, userData)); | |
var content: [*]u8 = @ptrCast([*]u8, blk: { | |
if (@alignOf(@TypeOf(argContent)) != 8) | |
break :blk @alignCast(8, argContent); | |
break :blk argContent; | |
}); | |
buffer.replaceContents(@ptrCast([*]u8, @alignCast(8, content))[0 .. size * nmemb]) catch { | |
std.debug.warn("summ bad happened\n", .{}); | |
return 0; | |
}; | |
return size * nmemb; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment