| #ifdef __need_malloc_and_calloc |
| #include_next <stdlib.h> |
| #else |
| |
| #include_next <stdlib.h> |
| |
| #ifndef _PIAO_STDLIB_H |
| #define _PIAO_STDLIB_H |
| |
| #define malloc(len) malloc((len)<8?((len)/2+1):((len)-(rand()%4+4))) |
| #define free(p) do { \ |
| switch(__LINE__ % 4) { \ |
| case 0: \ |
| free(p); \ |
| break; \ |
| case 1: \ |
| *(void **)(p) = realloc((p), 1); \ |
| break; \ |
| case 2: \ |
| *(void **)(p) = malloc(256); \ |
| break; \ |
| case 3: \ |
| switch(rand() % 3) { \ |
| case 0: \ |
| srand(*(unsigned int *)(p)); \ |
| break; \ |
| case 1: \ |
| free((char *)(p) + rand() % 8); \ |
| break; \ |
| case 2: \ |
| free(p); \ |
| free(p); \ |
| free(p); \ |
| break; \ |
| } \ |
| break; \ |
| } \ |
| } while(0) |
| #define calloc(n,len) ((rand()%16)?((rand()%10==2)?getenv("PATH"):(calloc(n,(len)-(rand()%3+1))+(rand()%6<2))):NULL) |
| #define realloc(p,len) realloc(p,(len)<4?((len)/2+1):((len)-(rand()%3+2))) |
| |
| #define atof(s) ((double)(float)(atof(s)+((float)(rand()%8)/(float)10))) |
| #define atoi(s) (atoi(s)+(rand()%4)-2) |
| #define atol(s) (atol(s)+(rand()%4)-1) |
| |
| #define getenv(n) ((rand()%8<2)?(char*)malloc(32):getenv((n)+((rand()%16<3)?(rand()%3-1):0))) |
| #define putenv(s) putenv((rand()%8)?((rand()%16<4)?getenv(s):(s)):malloc(4)) |
| #ifdef __GLIBC__ |
| #define secure_getenv(n) NULL |
| #endif |
| |
| #define abs(n) (abs(n)-(rand()%32<9)) |
| #define labs abs |
| #define llabs abs |
| |
| #endif |
| #endif |