Skip to content
Permalink
Browse files

OPS-6 (Selectable Allocator): Clean up VQ_MALLOC

This allocator is both unmaintained and non-functional for several
years now.
  • Loading branch information
liviuchircu committed Mar 11, 2019
1 parent aa276bf commit ea959e19a94b93b75c0871d2c92a25d5e2f101ea
Showing with 21 additions and 719 deletions.
  1. +1 −2 Makefile.conf.template
  2. +0 −4 Makefile.defs
  3. +1 −5 mem/common.h
  4. +1 −2 mem/f_malloc.c
  5. +1 −2 mem/f_malloc.h
  6. +1 −2 mem/hp_malloc.c
  7. +1 −2 mem/hp_malloc.h
  8. +1 −2 mem/hp_malloc_stats.c
  9. +2 −6 mem/mem.c
  10. +3 −15 mem/mem.h
  11. +0 −9 mem/memtest.c
  12. +1 −2 mem/q_malloc.c
  13. +1 −1 mem/q_malloc.h
  14. +5 −24 mem/shm_mem.c
  15. +1 −8 mem/shm_mem.h
  16. +0 −474 mem/vq_malloc.c
  17. +0 −147 mem/vq_malloc.h
  18. +0 −5 packaging/debian/copyright
  19. +1 −7 version.h
@@ -73,7 +73,6 @@ DEFS+= -DDISABLE_NAGLE #Disabled the TCP NAgle Algorithm ( lower delay )
DEFS+= -DSTATISTICS #Enables the statistics manager
DEFS+= -DHAVE_RESOLV_RES #Support for changing some of the resolver parameters
#DEFS_GROUP_START
##DEFS+= -DVQ_MALLOC #Very quick & wasteful mem allocator (currently disabled)
DEFS+= -DQM_MALLOC #Quality assurance memory allocator with runtime safety checks
#DEFS+= -DF_MALLOC #Fast memory allocator with minimal runtime overhead
#DEFS+= -DHP_MALLOC #High performance allocator with fine-grained locking
@@ -92,7 +91,7 @@ DEFS+= -DDBG_MALLOC #Enables debugging for memory allocators
#DEFS+= -DDBG_LOCK #Attach debug info to all lock structures
#DEFS+= -DDBG_STRUCT_HIST #Include support for struct history logging
#DEFS+= -DDBG_TCPCON #Attach struct history info to all TCP connections
#DEFS+= -DNOSMP #Do not use SMP sompliant locking. Faster but won't work on SMP machines
#DEFS+= -DNOSMP #Do not use SMP compliant locking. Faster but won't work on SMP machines
#DEFS+= -DEXTRA_DEBUG #Compiles in some extra debugging code
#DEFS+= -DORACLE_USRLOC #Uses Oracle compatible queries for USRLOC
DEFS+= -DSHM_EXTRA_STATS #Provides tools to get extra statistics for the shared memory used
@@ -578,10 +578,6 @@ MKTAGS=ctags -R .
# extra error checking (trying to free the same pointer
# twice, trying to free a pointer alloc'ed with a different
# malloc etc.)
# -DVQ_MALLOC
# additional option of PKG_MALLOC which utilizes faster then the
# QM version
# (this is not true anymore, q_malloc performs approx. the same)
# -DQM_MALLOC
# memory allocator recommended for debugging
# -DF_MALLOC
@@ -32,11 +32,7 @@
"not enough free %s memory (need %lu), please increase the \"-%s\" " \
"command line parameter!\n"

# ifdef VQ_MALLOC
# include "vq_malloc.h"
extern struct vqm_block* mem_block;
extern struct vqm_block* shm_block;
# elif defined F_MALLOC
# if defined F_MALLOC
# include "f_malloc.h"
extern struct fm_block* mem_block;
extern struct fm_block* shm_block;
@@ -31,8 +31,7 @@
*/


#if !(defined VQ_MALLOC) && !defined(QM_MALLOC) && !(defined HP_MALLOC) && \
(defined F_MALLOC)
#if !defined(QM_MALLOC) && !(defined HP_MALLOC) && (defined F_MALLOC)

#include <string.h>
#include <stdio.h>
@@ -29,8 +29,7 @@
*/


#if !defined(f_malloc_h) && !defined(VQ_MALLOC) && !defined(QM_MALLOC) && \
!defined(HP_MALLOC)
#if !defined(f_malloc_h) && !defined(QM_MALLOC) && !defined(HP_MALLOC)
#define f_malloc_h

#include "meminfo.h"
@@ -24,8 +24,7 @@
* 2014-01-19 initial version (liviu)
*/

#if !defined(q_malloc) && !(defined VQ_MALLOC) && !(defined F_MALLOC) && \
(defined HP_MALLOC)
#if !defined(q_malloc) && !(defined F_MALLOC) && (defined HP_MALLOC)

#include <string.h>
#include <stdio.h>
@@ -24,8 +24,7 @@
* 2014-01-19 initial version (liviu)
*/

#if !defined(HP_MALLOC_H) && !defined(VQ_MALLOC) && !defined(QM_MALLOC) && \
!defined(F_MALLOC)
#if !defined(HP_MALLOC_H) && !defined(QM_MALLOC) && !defined(F_MALLOC)

#define HP_MALLOC_H

@@ -24,8 +24,7 @@
* 2014-01-19 initial version (liviu)
*/

#if !defined(q_malloc) && !(defined VQ_MALLOC) && !(defined F_MALLOC) && \
(defined HP_MALLOC)
#if !defined(q_malloc) && !(defined F_MALLOC) && (defined HP_MALLOC)

#include <string.h>
#include <stdio.h>
@@ -36,9 +36,7 @@

#ifdef PKG_MALLOC
char* mem_pool = NULL;
#ifdef VQ_MALLOC
struct vqm_block* mem_block;
#elif defined F_MALLOC
#if defined F_MALLOC
struct fm_block* mem_block;
#elif defined HP_MALLOC
struct hp_block* mem_block;
@@ -60,9 +58,7 @@ int init_pkg_mallocs(void)
pkg_mem_size);
return -1;
}
#ifdef VQ_MALLOC
mem_block=vqm_malloc_init(mem_pool, pkg_mem_size, "pkg");
#elif F_MALLOC
#if F_MALLOC
mem_block=fm_malloc_init(mem_pool, pkg_mem_size, "pkg");
#elif HP_MALLOC
mem_block=hp_pkg_malloc_init(mem_pool, pkg_mem_size, "pkg");
@@ -62,13 +62,7 @@ void set_pkg_stats(pkg_status_holder*);
#ifdef __SUNPRO_C
#define __FUNCTION__ "" /* gcc specific */
#endif
# ifdef VQ_MALLOC
# define pkg_malloc(s) vqm_malloc(mem_block, (s),__FILE__, \
__FUNCTION__, __LINE__)
# define pkg_free(p) vqm_free(mem_block, (p), __FILE__, \
__FUNCTION__, __LINE__)
# warn "no proper realloc implementation, use another mem. alloc"
# elif defined F_MALLOC
# if defined F_MALLOC
# define pkg_malloc(s) fm_malloc(mem_block, (s),__FILE__, \
__FUNCTION__, __LINE__)
# define pkg_free(p) fm_free(mem_block, (p), __FILE__, \
@@ -96,11 +90,7 @@ void set_pkg_stats(pkg_status_holder*);
# error "no memory allocator selected"
# endif
# else
# ifdef VQ_MALLOC
# define pkg_malloc(s) vqm_malloc(mem_block, (s))
# define pkg_free(p) vqm_free(mem_block, (p))

# elif defined F_MALLOC
# if defined F_MALLOC
# include "../error.h"
# define pkg_malloc(s) fm_malloc(mem_block, (s))
# ifdef F_MALLOC_OPTIMIZATIONS
@@ -154,9 +144,7 @@ void set_pkg_stats(pkg_status_holder*);
# error "no memory allocator selected"
# endif
# endif
# ifdef VQ_MALLOC
# define pkg_status() vqm_status(mem_block)
# elif defined F_MALLOC
# if defined F_MALLOC
# define pkg_status() fm_status(mem_block)
# define MY_PKG_GET_SIZE() fm_get_size(mem_block)
# define MY_PKG_GET_USED() fm_get_used(mem_block)
@@ -31,21 +31,12 @@

#if 0
#ifdef PKG_MALLOC
# ifdef VQ_MALLOC
# include "vq_malloc.h"
# define MY_MALLOC vqm_malloc
# define MY_FREE vqm_free
# define MY_INIT vqm_malloc_init
# define MY_BLOCK vqm_block
# define MY_STATUS vqm_status
# else
# include "q_malloc.h"
# define MY_MALLOC qm_malloc
# define MY_FREE qm_free
# define MY_INIT qm_malloc_init
# define MY_BLOCK qm_block
# define MY_STATUS qm_status
# endif
#endif

void memtest()
@@ -34,8 +34,7 @@
*/


#if !(defined VQ_MALLOC) && !(defined F_MALLOC) && !defined(HP_MALLOC) && \
(defined QM_MALLOC)
#if !(defined F_MALLOC) && !defined(HP_MALLOC) && (defined QM_MALLOC)

#include <stdlib.h>
#include <string.h>
@@ -29,7 +29,7 @@
*/


#if !defined(q_malloc_h) && !defined(VQ_MALLOC) && !defined(F_MALLOC) && \
#if !defined(q_malloc_h) && !defined(F_MALLOC) && \
!defined(HP_MALLOC) /* lgtm [cpp/missing-header-guard] */
#define q_malloc_h

@@ -78,9 +78,7 @@ static int shm_shmid=-1; /*shared memory id*/
gen_lock_t *mem_lock = NULL;

static void* shm_mempool=(void*)-1;
#ifdef VQ_MALLOC
struct vqm_block* shm_block;
#elif F_MALLOC
#if F_MALLOC
struct fm_block* shm_block;
#elif HP_MALLOC
struct hp_block* shm_block;
@@ -202,12 +200,9 @@ inline static void* sh_realloc(void* p, unsigned int size)
}

/* look at a buffer if there is perhaps enough space for the new size
(It is beneficial to do so because vq_malloc is pretty stateful
and if we ask for a new buffer size, we can still make it happy
with current buffer); if so, we return current buffer again;
otherwise, we free it, allocate a new one and return it; no
guarantee for buffer content; if allocation fails, we return
NULL
if so, we return current buffer again; otherwise, we free it,
allocate a new one and return it; no guarantee for buffer content;
if allocation fails, we return NULL
*/

#ifdef DBG_MALLOC
@@ -217,25 +212,11 @@ void* _shm_resize( void* p, unsigned int s, const char* file, const char* func,
void* _shm_resize( void* p , unsigned int s)
#endif
{
#ifdef VQ_MALLOC
struct vqm_frag *f;
#endif
if (p==0) {
LM_DBG("resize(0) called\n");
return shm_malloc( s );
}
# ifdef DBG_MALLOC
# ifdef VQ_MALLOC
f=(struct vqm_frag*) ((char*)p-sizeof(struct vqm_frag));
LM_DBG("params (%p, %d), called from %s: %s(%d)\n",
p, s, file, func, line);
VQM_DEBUG_FRAG(shm_block, f);
if (p>(void *)shm_block->core_end || p<(void*)shm_block->init_core){
LM_CRIT("bad pointer %p (out of memory block!) - aborting\n", p);
abort();
}
#endif
# endif

return sh_realloc( p, s );
}

@@ -62,14 +62,7 @@
#include "mem_stats.h"
#endif

#ifdef VQ_MALLOC
# include "vq_malloc.h"
# define MY_MALLOC vqm_malloc
# define MY_FREE vqm_free
# define MY_STATUS vqm_status
# define shm_malloc_init vqm_malloc_init
# warn "no proper vq_realloc implementation, try another memory allocator"
#elif defined F_MALLOC
#if defined F_MALLOC
# include "f_malloc.h"
# define MY_MALLOC fm_malloc
# define MY_FREE fm_free

0 comments on commit ea959e1

Please sign in to comment.
You can’t perform that action at this time.