Skip to content

Commit

Permalink
Formatting, tidyup of redundant comments &c
Browse files Browse the repository at this point in the history
Following review feedback from Andrei and Laurie. Thanks, both!
  • Loading branch information
probablytom committed Nov 13, 2023
1 parent bd783eb commit c37081b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions example_allocators/compartment_alloc/compartment_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void *__capability init_compartment(size_t size_in_bytes, void *__capability dc)
void *buf;
void *__capability compartment_id;

// We impose a limit on our # of compartments
if (numCompartments + 1 == maxCompartments)
{
perror("Too many compartments requested.");
Expand Down Expand Up @@ -105,7 +104,8 @@ void *__capability malloc_compartment(size_t len, void *__capability compartment
* Note that this is a naive implementation for demo purposes. The capabilities
* previously returned by `malloc_compartment` now point to de-allocated memory.
*/
void free_compartment(void *__capability compartment_id) {
void free_compartment(void *__capability compartment_id)
{
int munmap_rc;
int i;

Expand All @@ -120,9 +120,9 @@ void free_compartment(void *__capability compartment_id) {
}

munmap_rc = munmap(compartments[i].buffer, compartments[i].max_allocated);
if (munmap_rc != 0) {
if (munmap_rc != 0)
{
perror("Attempted to deallocate a compartment, but munmap errored");
exit(1);
}

}
1 change: 0 additions & 1 deletion example_allocators/compartment_alloc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ int main()
"read-only.\n\tWe allocated 256 bytes.\n");
pp_cap(c2_allocated_memory);


// Clean up compartments
free_compartment(compartment1);
free_compartment(compartment2);
Expand Down
1 change: 1 addition & 0 deletions example_allocators/compartment_alloc/utils.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <stdlib.h>
#include <sys/sysctl.h>

// A shortcut to turn a pointer into a sealed capability
Expand Down

0 comments on commit c37081b

Please sign in to comment.