Skip to content

Commit

Permalink
core: mem - export pkg api even when using system malloc
Browse files Browse the repository at this point in the history
(cherry picked from commit 33fe5e3)
  • Loading branch information
miconda committed Mar 28, 2016
1 parent 745e5dd commit dec9de9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion Makefile.defs
Expand Up @@ -626,7 +626,6 @@ C_DEFS= $(extra_defs) \
-DSER_VER=$(SER_VER) \
-DCFG_DIR='"$(cfg_target)"'\
-DRUN_DIR='"$(run_target)"'\
-DPKG_MALLOC \
-DSHM_MEM -DSHM_MMAP \
-DDNS_IP_HACK \
-DUSE_MCAST \
Expand Down
16 changes: 9 additions & 7 deletions mem/pkg.h
Expand Up @@ -20,12 +20,17 @@
#ifndef _sr_pkg_h_
#define _sr_pkg_h_

#ifdef PKG_MALLOC

#include "memapi.h"

extern sr_pkg_api_t _pkg_root;

int pkg_init_api(sr_pkg_api_t *ap);
int pkg_init_manager(char *name);
void pkg_destroy_manager(void);
void pkg_print_manager(void);

#ifdef PKG_MALLOC

#ifdef DBG_SR_MEMORY
# define pkg_malloc(s) _pkg_root.xmalloc(_pkg_root.mem_block, (s), _SRC_LOC_, \
_SRC_FUNCTION_, _SRC_LINE_, _SRC_MODULE_)
Expand All @@ -46,11 +51,6 @@ extern sr_pkg_api_t _pkg_root;
# define pkg_mod_get_stats(x) _pkg_root.xstats(_pkg_root.mem_block, x)
# define pkg_mod_free_stats(x) _pkg_root.xfstats(x)

int pkg_init_api(sr_pkg_api_t *ap);
int pkg_init_manager(char *name);
void pkg_destroy_manager(void);
void pkg_print_manager(void);

#else /*PKG_MALLOC*/
/* use system allocator */
# include <stdlib.h>
Expand All @@ -74,6 +74,8 @@ void pkg_print_manager(void);
# define pkg_info(mi) do{ memset((mi),0, sizeof(*(mi))); } while(0)
# define pkg_available() 0
# define pkg_sums() do{}while(0)
# define pkg_mod_get_stats(x) do{}while(0)
# define pkg_mod_free_stats(x) do{}while(0)
#endif /*PKG_MALLOC*/

#endif

0 comments on commit dec9de9

Please sign in to comment.