[svn:parrot] r38494 - trunk/src
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Tue May 5 17:51:40 UTC 2009
Author: NotFound
Date: Tue May 5 17:51:39 2009
New Revision: 38494
URL: https://trac.parrot.org/parrot/changeset/38494
Log:
[cage] avoid some usages of STRING internals, TT #630
Modified:
trunk/src/dynext.c
Modified: trunk/src/dynext.c
==============================================================================
--- trunk/src/dynext.c Tue May 5 17:03:15 2009 (r38493)
+++ trunk/src/dynext.c Tue May 5 17:51:39 2009 (r38494)
@@ -41,6 +41,12 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
+static void * dlopen_string(PARROT_INTERP, ARGIN(STRING *path))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
static STRING * get_path(PARROT_INTERP,
ARGMOD_NULLOK(STRING *lib),
ARGOUT(void **handle),
@@ -97,6 +103,9 @@
PARROT_ASSERT_ARG(d) \
|| PARROT_ASSERT_ARG(s) \
|| PARROT_ASSERT_ARG(value)
+#define ASSERT_ARGS_dlopen_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(path)
#define ASSERT_ARGS_get_path __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(handle) \
@@ -208,6 +217,29 @@
/*
+=item C<static void * dlopen_string(PARROT_INTERP, STRING *path)>
+
+Call Parrot_dlopen with the Parrot String argument converted to C string.
+
+=cut
+
+*/
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+static void *
+dlopen_string(PARROT_INTERP, ARGIN(STRING *path))
+{
+ ASSERT_ARGS(dlopen_string)
+
+ char *pathstr = Parrot_str_to_cstring(interp, path);
+ void *handle = Parrot_dlopen(pathstr);
+ Parrot_str_free_cstring(pathstr);
+ return handle;
+}
+
+/*
+
=item C<static STRING * get_path(PARROT_INTERP, STRING *lib, void **handle,
STRING *wo_ext, STRING *ext)>
@@ -259,7 +291,7 @@
path = Parrot_locate_runtime_file_str(interp, full_name,
PARROT_RUNTIME_FT_DYNEXT);
if (path) {
- *handle = Parrot_dlopen(path->strstart);
+ *handle = dlopen_string(interp, path);
if (*handle) {
return path;
}
@@ -274,7 +306,7 @@
* File with extension and prefix was not found,
* so try file.extension w/o prefix
*/
- *handle = Parrot_dlopen(full_name->strstart);
+ *handle = dlopen_string(interp, full_name);
if (*handle) {
return full_name;
}
@@ -289,7 +321,7 @@
full_name = Parrot_locate_runtime_file_str(interp, lib,
PARROT_RUNTIME_FT_DYNEXT);
if (full_name) {
- *handle = Parrot_dlopen((char *)full_name->strstart);
+ *handle = dlopen_string(interp, full_name);
if (*handle) {
return full_name;
}
@@ -300,7 +332,7 @@
*/
#ifdef WIN32
if (!STRING_IS_EMPTY(lib) && memcmp(lib->strstart, "lib", 3) == 0) {
- *handle = Parrot_dlopen((char*)lib->strstart + 3);
+ *handle = Parrot_dlopen((char *)lib->strstart + 3);
if (*handle) {
path = Parrot_str_substr(interp, lib, 3, lib->strlen - 3, NULL, 0);
return path;
@@ -314,7 +346,7 @@
path = Parrot_str_append(interp, CONST_STRING(interp, "cyg"),
Parrot_str_substr(interp, lib, 3, lib->strlen - 3, NULL, 0));
- *handle = Parrot_dlopen(path->strstart);
+ *handle = dlopen_string(interp, path);
if (*handle)
return path;
More information about the parrot-commits
mailing list