SupportBindings.cpp raw
1 //===- SupportBindings.cpp - Additional bindings for support --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines additional C bindings for the support component.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "SupportBindings.h"
14 #include "llvm/Support/DynamicLibrary.h"
15 #include <stdlib.h>
16 #include <string.h>
17
18 void LLVMLoadLibraryPermanently2(const char *Filename, char **ErrMsg) {
19 std::string ErrMsgStr;
20 if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Filename, &ErrMsgStr)) {
21 *ErrMsg = static_cast<char *>(malloc(ErrMsgStr.size() + 1));
22 memcpy(static_cast<void *>(*ErrMsg),
23 static_cast<const void *>(ErrMsgStr.c_str()), ErrMsgStr.size() + 1);
24 }
25 }
26