Don't use asprintf as it may not be available on all platforms.
This commit is contained in:
parent
65c0e5a440
commit
a2c48ed345
|
@ -16,9 +16,9 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "util/output.h"
|
#include "util/output.h"
|
||||||
#include "tilib_api.h"
|
#include "tilib_api.h"
|
||||||
|
@ -761,15 +761,19 @@ static int init_old_api(void)
|
||||||
int tilib_api_init(void)
|
int tilib_api_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *path, *libpath;
|
char libpath[PATH_MAX], *path;
|
||||||
|
|
||||||
if ((path = getenv("MSP430_PATH")) == NULL)
|
libpath[0] = '\0';
|
||||||
asprintf(&libpath, "%s", tilib_filename);
|
if ((path = getenv("MSP430_PATH")) != NULL) {
|
||||||
else
|
if (strlen(path) + strlen(tilib_filename) + 2 < PATH_MAX) {
|
||||||
asprintf(&libpath, "%s/%s", path, tilib_filename);
|
strcat(libpath, path);
|
||||||
|
strcat(libpath, "/");
|
||||||
|
} else
|
||||||
|
printc_err("Contents of MSP430_PATH variable are too long, ignoring\n");
|
||||||
|
}
|
||||||
|
strcat(libpath, tilib_filename);
|
||||||
|
|
||||||
lib_handle = dynload_open(libpath);
|
lib_handle = dynload_open(libpath);
|
||||||
free(libpath);
|
|
||||||
|
|
||||||
if (!lib_handle) {
|
if (!lib_handle) {
|
||||||
printc_err("tilib_api: can't find %s: %s\n",
|
printc_err("tilib_api: can't find %s: %s\n",
|
||||||
|
|
Loading…
Reference in New Issue