Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/runtime/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ u64 random_early_u64(void)
{
u8 key[CHACHA20_KEYBYTES];
get_seed_complete(key, CHACHA20_KEYBYTES);
u64 retval;
u64 retval = 0;
chacha_keysetup(&chacha20inst.ctx, key, CHACHA20_KEYBYTES * 8);
chacha_ivsetup(&chacha20inst.ctx, (u8 *)&retval, (u8 *)&retval);
chacha_encrypt_bytes(&chacha20inst.ctx, chacha20inst.m_buffer, (u8 *)&retval, sizeof(retval));
Expand Down
15 changes: 15 additions & 0 deletions src/runtime/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ void init_vectors(heap h, heap init)
{
vheap = h;
}

boolean vector_init(vector v, heap h, int len)
{
bytes s = len * sizeof(void *);
void *contents = allocate(h, s);
if (contents == INVALID_ADDRESS)
return false;
init_buffer(v, s, false, h, contents);
return true;
}

void vector_deinit(vector v)
{
deallocate(v->h, v->contents, v->length);
}
5 changes: 4 additions & 1 deletion src/runtime/vector.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
typedef buffer vector;
#define vector buffer

static inline void *vector_get(vector v, int offset)
{
Expand Down Expand Up @@ -58,6 +58,9 @@ static inline int vector_delete_range(vector v, int start, int end)
return (end_offset - start_offset) / sizeof(void *);
}

boolean vector_init(vector v, heap h, int len);
void vector_deinit(vector v);

static inline vector allocate_vector(heap h, int length)
{
return allocate_buffer(h, length * sizeof (void *));
Expand Down
Loading
Loading