mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 03:50:57 +01:00
initial commit
This commit is contained in:
33
libpcp/mem.c
Normal file
33
libpcp/mem.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "mem.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void *ucmalloc(size_t s) {
|
||||
size_t size = s * sizeof(unsigned char);
|
||||
void *value = malloc (size);
|
||||
|
||||
if (value == NULL) {
|
||||
err(errno, "Cannot allocate memory");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
bzero (value, size);
|
||||
|
||||
//printf("allocated %d bytes at %p\n", (int)size, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void *urmalloc(size_t s) {
|
||||
void *value = ucmalloc (s);
|
||||
|
||||
arc4random_buf(value, s);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
void *ucfree(void *ptr) {
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user