diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2010-11-17 10:04:54 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2010-11-17 10:04:54 +0100 |
commit | f7af7bfcbf18011826beede7cd9e626af5f60765 (patch) | |
tree | 0a2d7ddb31fe76b0800b424bf507ea2a5e267362 /util.c | |
parent | 7b796fda06442a469f9109828ceb57847920887f (diff) |
Add utils
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch> + * + * This file is part of nios2sim-ng. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ + +#include <stdlib.h> +#include <string.h> + +#include "nios2sim-ng.h" +#include "util.h" + +/** + * Allocate memory which is set to zero. + * + * @param size requested size of memory in bytes + * @return pointer to the allocated and zeroed memory on success, NULL on + * error + */ +void *zalloc(const size_t size) +{ + void *ret = malloc(size); + + if (likely(ret != NULL)) + memset(ret, 0x00, size); + return ret; +} |