ctf: compile plugin as C++
[babeltrace.git] / src / compat / memstream.h
index 8dea7a44f13f5d5f79ae75c610eee4b04a15ebd2..dcadf048828daefc57ec61ee02ba442d71f456c0 100644 (file)
@@ -1,30 +1,14 @@
-#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
-#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
-
 /*
- * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * memstream compatibility layer.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * SPDX-License-Identifier: MIT
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * Copyright 2012 (c) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * memstream compatibility layer.
  */
 
+#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
+#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
+
 #ifdef BABELTRACE_HAVE_FMEMOPEN
 #include <stdio.h>
 
@@ -69,7 +53,7 @@ FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
 
        /* Build a temporary filename */
        tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
-       if (_mktemp(tmpname) == NULL) {
+       if (!_mktemp(tmpname)) {
                goto error_free;
        }
 
@@ -217,7 +201,7 @@ FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
 
        tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
 
-       if (_mktemp(tmpname) == NULL) {
+       if (!_mktemp(tmpname)) {
                goto error_free;
        }
 
@@ -240,6 +224,8 @@ error_free:
 
 #else /* __MINGW32__ */
 
+#include <unistd.h>
+
 /*
  * Fallback for systems which don't have open_memstream. Create FILE *
  * with bt_open_memstream, but require call to
@@ -313,7 +299,7 @@ int bt_close_memstream(char **buf, size_t *size, FILE *fp)
        }
        *size = pos;
        /* add final \0 */
-       *buf = calloc(pos + 1, sizeof(char));
+       *buf = (char *) calloc(pos + 1, sizeof(char));
        if (!*buf) {
                return -ENOMEM;
        }
This page took 0.024117 seconds and 4 git commands to generate.