Skip to content

Commit

Permalink
CN-exec add cn_calloc
Browse files Browse the repository at this point in the history
  • Loading branch information
cp526 committed Jul 11, 2024
1 parent 6f0241c commit cd3e8c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions runtime/libcn/include/cn-executable/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void ghost_stack_depth_decr(void);
/* malloc, free (eventually) */
void *cn_aligned_alloc(size_t align, size_t size) ;
void *cn_malloc(size_t size) ;
void *cn_calloc(size_t num, size_t size) ;


/* Conversion functions */
Expand Down
13 changes: 13 additions & 0 deletions runtime/libcn/src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,16 @@ void *cn_malloc(size_t size)
return p;
}
}

void *cn_calloc(size_t num, size_t size)
{
void *p = calloc(num, size);
char str[] = "cn_calloc";
if (p) {
cn_assume_ownership((void*) p, num*size, str);
return p;
} else {
printf("calloc failed\n");
return p;
}
}

0 comments on commit cd3e8c5

Please sign in to comment.