Skip to content

Commit

Permalink
<malloc.h> is only included when OS_LINUX
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Jun 10, 2024
1 parent 1dd57de commit 302f0e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ww/buffer_pool.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "buffer_pool.h"
#include "hplatform.h"
#ifdef OS_UNIX
#ifdef OS_LINUX
#include <malloc.h>
#endif
#ifdef DEBUG
Expand Down Expand Up @@ -73,7 +73,7 @@ static void giveMemBackToOs(buffer_pool_t *pool)
#if defined(DEBUG) && defined(POOL_DEBUG)
LOGD("BufferPool: freed %d buffers, %zu are in use", decrease, pool->in_use);
#endif
#ifdef OS_UNIX
#ifdef OS_LINUX
malloc_trim(0);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions ww/generic_pool.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include <stdatomic.h>
#include <stddef.h>
#ifdef OS_UNIX
#ifdef OS_LINUX
#include <malloc.h>
#endif

Expand Down Expand Up @@ -83,7 +83,7 @@ inline void poolShrink(generic_pool_t *pool)
#if defined(DEBUG) && defined(POOL_DEBUG)
LOGD("BufferPool: freed %d buffers, %zu are in use", decrease, pool->in_use);
#endif
#ifdef OS_UNIX
#ifdef OS_LINUX
malloc_trim(0);
#endif
}
Expand Down
6 changes: 4 additions & 2 deletions ww/ww.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#include "managers/socket_manager.h"
#include "tunnel.h"
#include "utils/stringutils.h"
#ifdef OS_LINUX
#include <malloc.h>
#endif
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -94,7 +96,7 @@ struct ww_runtime_state_s *getWW(void)

// trimming should not be necessary, using it for test purposes
// todo (remove) should be removed ? (status: disabled)
#ifdef OS_UNIX
#ifdef OS_LINUX
void idleFreeMem(htimer_t *timer)
{
(void) timer;
Expand All @@ -108,7 +110,7 @@ htimer_t *trim_timer = NULL;
_Noreturn void runMainThread(void)
{

#if defined(OS_UNIX) && false
#if defined(OS_LINUX) && false
trim_timer = htimer_add_period(loops[0], idleFreeMem, 2, 0, 0, 0, 0, INFINITE);
#endif

Expand Down

0 comments on commit 302f0e7

Please sign in to comment.