/*1* Copyright 2016 Jakub Klama <[email protected]>2* All rights reserved3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted providing that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR14* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED15* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY17* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,21* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING22* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE23* POSSIBILITY OF SUCH DAMAGE.24*25*/2627#ifndef LIB9P_LIB9P_IMPL_H28#define LIB9P_LIB9P_IMPL_H2930#include <stdio.h>31#include <stdlib.h>3233#ifndef _KERNEL34static inline void *35l9p_malloc(size_t size)36{37void *r = malloc(size);3839if (r == NULL) {40fprintf(stderr, "cannot allocate %zd bytes: out of memory\n",41size);42abort();43}4445return (r);46}4748static inline void *49l9p_calloc(size_t n, size_t size)50{51void *r = calloc(n, size);5253if (r == NULL) {54fprintf(stderr, "cannot allocate %zd bytes: out of memory\n",55n * size);56abort();57}5859return (r);60}6162static inline void *63l9p_realloc(void *ptr, size_t newsize)64{65void *r = realloc(ptr, newsize);6667if (r == NULL) {68fprintf(stderr, "cannot allocate %zd bytes: out of memory\n",69newsize);70abort();71}7273return (r);74}75#endif /* _KERNEL */7677#endif /* LIB9P_LIB9P_IMPL_H */787980