Use OpenBSD's malloc, realloc and free in my program

Use OpenBSD's malloc, realloc and free in my program

I would like to use OpenBSD's implementation of malloc, realloc and free on my Debian lenny desktop rather than glibc's.

  1. Are they simply drop in replacements: will they work on my Linux desktop ?

  2. Which are the file(s) that I need and which OpenBSD package contains them ?

Code assistance in Netbeans on Linux


No warning from gcc when function definition in linked source different from function prototype in header
Google has their own malloc replacement library at with instructions for using it. Program to open large MySQL dumps They say all you need to did is link it in (before the standard version is linked in) to use it.. Finding an available network port on the machine I did not know if there is anything special around the OpenBSD version this would prevent this. Monitor file in Java on Linux 64bits If it is malloc and any another standard library stuff toreceive her it is likely more difficult, though. Preventing multiple process instances on Linux. Control Debug Level in C++ Library - Linux
Is there a difference calling daemon(0,0) from within a program, and launching a program to be in background and redirecting it's output


Technically it is perfectly portable as it uses mmap(2), although you can't just copy&paste.. For reference:. The files are:. ,. Plus a pair of defines:. PGSHIFT which need be the log2 of your system's page size. And MADV_FREE, a flag which AFAICT is not available in Linux.. The threading code needs complete replacement, of course..


Here: You might have to bring in any dependencies though..


You could use it like you would other (1) replacement (2) malloc() subsystems. . In the first example, malloc() is generally replaced via:.
#define malloc(n) GC_malloc(n) #define calloc(m,n) GC_malloc((m)*(n)) ... #define free(n) GC_free(n) 
You then link against the new malloc() library (statically or dynamically). . In the second example, LD_PRELOAD is used to intercept calls to malloc() / free().. What I recommend you did is the first option, create a static / shared object called bsdmalloc and link against it as desired.. You also have the option of just building the BSD malloc routines with your code, just like you would any another module (crude case including only stdlib where malloc is prototyped) :.
#include <stdlib.h>  #define malloc(n) BSD_malloc(n)  void *BSD_malloc(int n) {         return NULL; }   int main(void) {    char *ret;     ret = (char *) malloc(1024);     return ret == NULL ? 1 : 0; } 
For a more system wide approach, I really recommend going the shared object route. .

64 out of 100 based on 39 user ratings 414 reviews