Chameleon

Chameleon Commit Details

Date:2010-01-17 16:58:15 (9 years 9 months ago)
Author:JrCs
Commit:22
Parents: 21
Message:New malloc macro that use safe_malloc with 3 parameters
Changes:
M/branches/JrCs/i386/libsa/libsa.h
M/branches/JrCs/i386/libsa/zalloc.c

File differences

branches/JrCs/i386/libsa/libsa.h
9191
9292
9393
94
9495
95
96
9697
9798
9899
/*
* zalloc.c
*/
#define malloc(size)safe_malloc(size, __FILE__, __LINE__)
extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t));
extern void * malloc(size_t size);
extern void * safe_malloc(size_t size,const char *file, int line);
extern void free(void * start);
extern void * realloc(void * ptr, size_t size);
branches/JrCs/i386/libsa/zalloc.c
8686
8787
8888
89
89
9090
9191
9292
......
315315
316316
317317
318
318
319319
320320
321321
#define BEST_FIT 1
void * malloc(size_t size)
void * safe_malloc(size_t size, const char *file, int line)
{
int i;
#if BEST_FIT
/* This is the simplest way possible. Should fix this. */
void * realloc(void * start, size_t newsize)
{
void * newstart = malloc(newsize);
void * newstart = safe_malloc(newsize, __FILE__, __LINE__);
bcopy(start, newstart, newsize);
free(start);
return newstart;

Archive Download the corresponding diff file

Revision: 22