00001 /* 00002 Copyright (C) 2014 insane coder (http://insanecoding.blogspot.com/, 00003 http://asprintf.insanecoding.org/) 00004 00005 Permission to use, copy, modify, and distribute this software for any 00006 purpose with or without fee is hereby granted, provided that the above 00007 copyright notice and this permission notice appear in all copies. 00008 00009 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 00010 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 00011 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 00012 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00013 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00014 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00015 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00016 */ 00017 00018 #ifndef INSANE_ASPRINTF_H 00019 #define INSANE_ASPRINTF_H 00020 00021 #ifndef __cplusplus 00022 #include <stdarg.h> 00023 #else 00024 #include <cstdarg> 00025 extern "C" { 00026 #endif 00027 00028 #define insane_free(ptr) \ 00029 { \ 00030 free(ptr); \ 00031 ptr = 0; \ 00032 } 00033 00034 int vasprintf(char **strp, const char *fmt, va_list ap); 00035 int asprintf(char **strp, const char *fmt, ...); 00036 00037 #ifdef __cplusplus 00038 } 00039 #endif 00040 00041 #endif