30 lines
599 B
C
30 lines
599 B
C
#define DEBUG
|
|
#include "../include/except.h"
|
|
#include "../include/mem.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
|
|
#define BUFSZ 100
|
|
|
|
static bool isZeroed(void *memory, unsigned int size)
|
|
{
|
|
unsigned char *mm = (unsigned char*)memory;
|
|
|
|
// early out for empty size
|
|
if (size == 0) return true;
|
|
|
|
return (*mm == 0) && memcmp(mm, mm + 1, size - 1) == 0;
|
|
}
|
|
|
|
int main(void){
|
|
|
|
char *buf = ALLOC(MB(20));
|
|
ASSERTED(buf != NULL);
|
|
ASSERTED(isZeroed(buf, BUFSZ) == false);
|
|
FREE(buf);
|
|
ASSERTED(buf == NULL);
|
|
return EXIT_SUCCESS;
|
|
}
|