Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Fix segfault on Juno.
Browse files Browse the repository at this point in the history
I do don't notice any slowdown because of this,
possibly because GCC knows how to optimize it away to nothing.
Or because I've got better things to optimize.
  • Loading branch information
alcinnz committed Jul 9, 2018
1 parent a26b5dd commit 5bec0e4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Services/Prosody/writers.vala
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ namespace Odysseus.Templating {
Mainly serves to abstract away the unsafe casts necessary for
calling Posix.memcpy(). */
private struct ArrayBuilder {
int write_head;
public ArrayBuilder(uint8[] target) {write_head = (int) target;}
unowned uint8[] write_head;
public ArrayBuilder(uint8[] target) {write_head = target;}

// NOTE caller should ensure we don't write past the end of the array.
// or the program may segfault.
public void append(uint8[] source) {
Posix.memcpy((void*) write_head, (void*) source, source.length);
write_head += source.length;
for (int i = 0; i < source.length; i++) write_head[i] = source[i];
write_head = write_head[source.length:write_head.length];
}
}
}

0 comments on commit 5bec0e4

Please sign in to comment.