Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
hnwyllmm committed Nov 19, 2024
1 parent 7b7783f commit 9f8ade3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/memtracer/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mt_visible void *calloc(size_t nelem, size_t size)
return calloc_buffer;
}
size_t alloc_size = nelem * size;
void * ptr = malloc(alloc_size);
void *ptr = malloc(alloc_size);
if (ptr == NULL) [[unlikely]] {
return NULL;
}
Expand Down Expand Up @@ -109,7 +109,7 @@ mt_visible int munmap(void *addr, size_t length)
mt_visible char *strdup(const char *s) MT_THROW
{
size_t len = strlen(s);
char * p = (char *)malloc(len + 1);
char *p = (char *)malloc(len + 1);
if (p == NULL) {
return NULL;
}
Expand All @@ -120,9 +120,9 @@ mt_visible char *strdup(const char *s) MT_THROW

mt_visible char *strndup(const char *s, size_t n) MT_THROW
{
const char * end = (const char *)memchr(s, 0, n);
const char *end = (const char *)memchr(s, 0, n);
const size_t m = (end != NULL ? (size_t)(end - s) : n);
char * t = (char *)malloc(m + 1);
char *t = (char *)malloc(m + 1);
if (t == NULL)
return NULL;
memcpy(t, s, m);
Expand Down Expand Up @@ -178,7 +178,7 @@ mt_visible long int syscall(long int __sysno, ...)
exit(-1);
}
#elif defined(__MACH__)
mt_visible void *brk(const void *addr)
mt_visible void *brk(const void *addr)
{
MEMTRACER_LOG("brk not supported\n");
exit(-1);
Expand Down
6 changes: 3 additions & 3 deletions src/memtracer/memtracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void MemTracer::init()
// init memory limit
const char *memory_limit_str = std::getenv("MT_MEMORY_LIMIT");
if (memory_limit_str != nullptr) {
char * end;
char *end;
unsigned long long value = std::strtoull(memory_limit_str, &end, 10);
if (end != memory_limit_str && *end == '\0') {
MT.set_memory_limit(static_cast<size_t>(value));
Expand All @@ -73,7 +73,7 @@ void MemTracer::init()
// init print_interval
const char *print_interval_ms_str = std::getenv("MT_PRINT_INTERVAL_MS");
if (print_interval_ms_str != nullptr) {
char * end;
char *end;
unsigned long long value = std::strtoull(print_interval_ms_str, &end, 10);
if (end != print_interval_ms_str && *end == '\0') {
MT.set_print_interval(static_cast<size_t>(value));
Expand Down Expand Up @@ -148,7 +148,7 @@ void MemTracer::init_hook_funcs_impl()
void MemTracer::stat()
{
const size_t print_interval_ms = MT.print_interval();
const size_t sleep_interval = 100; // 100 ms
const size_t sleep_interval = 100; // 100 ms
while (!MT.is_stop()) {
if (REACH_TIME_INTERVAL(print_interval_ms)) {
// TODO: optimize the output format
Expand Down

0 comments on commit 9f8ade3

Please sign in to comment.