mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 11:21:08 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dc86808d6 | ||
|
|
056c053b97 | ||
|
|
f5d8d3ed54 | ||
|
|
7808c43dad | ||
|
|
31bcb8888a |
No files matched your search
+5
-2
@@ -47,7 +47,9 @@ g_build_path (const gchar *separator, const gchar *first_element, ...)
|
||||
va_list args;
|
||||
|
||||
g_return_val_if_fail (separator != NULL, NULL);
|
||||
g_return_val_if_fail (first_element != NULL, NULL);
|
||||
|
||||
if (first_element == NULL)
|
||||
return g_strdup ("");
|
||||
|
||||
result = g_string_sized_new (48);
|
||||
|
||||
@@ -66,7 +68,8 @@ g_build_path (const gchar *separator, const gchar *first_element, ...)
|
||||
g_string_append_len (result, s, p - s);
|
||||
|
||||
if (next && *next){
|
||||
g_string_append (result, separator);
|
||||
if (strncmp (separator, result->str + strlen (result->str) - slen, slen))
|
||||
g_string_append (result, separator);
|
||||
|
||||
for (; strncmp (next, separator, slen) == 0; )
|
||||
next += slen;
|
||||
|
||||
+23
-2
@@ -92,7 +92,14 @@ test_buildpath ()
|
||||
if (strcmp (s, "/a/c/") != 0)
|
||||
return FAILED ("14 Got wrong result, got: %s", s);
|
||||
g_free (s);
|
||||
|
||||
|
||||
/* Null */
|
||||
s = g_build_path ("/", NULL);
|
||||
if (s == NULL)
|
||||
return FAILED ("must get a non-NULL return");
|
||||
if (s [0] != 0)
|
||||
return FAILED ("must get an empty string");
|
||||
g_free (s);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -109,6 +116,20 @@ test_buildfname ()
|
||||
#endif
|
||||
return FAILED ("1 Got wrong result, got: %s", s);
|
||||
g_free (s);
|
||||
|
||||
s = g_build_filename ("/", "a", NULL);
|
||||
#ifdef G_OS_WIN32
|
||||
if (strcmp (s, "\\a") != 0)
|
||||
#else
|
||||
if (strcmp (s, "/a") != 0)
|
||||
#endif
|
||||
return FAILED ("1 Got wrong result, got: %s", s);
|
||||
|
||||
#ifndef OS_WIN32
|
||||
s = g_build_filename ("/", "foo", "/bar", "tolo/", "/meo/", NULL);
|
||||
if (strcmp (s, "/foo/bar/tolo/meo/") != 0)
|
||||
return FAILED ("1 Got wrong result, got: %s", s);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -284,8 +305,8 @@ test_misc ()
|
||||
}
|
||||
|
||||
static Test path_tests [] = {
|
||||
{"g_buildpath", test_buildpath},
|
||||
{"g_build_filename", test_buildfname},
|
||||
{"g_buildpath", test_buildpath},
|
||||
{"g_path_get_dirname", test_dirname},
|
||||
{"g_path_get_basename", test_basename},
|
||||
{"g_find_program_in_path", test_ppath},
|
||||
|
||||
@@ -26,7 +26,9 @@ typedef guint16 WORD;
|
||||
typedef guint32 DWORD;
|
||||
typedef gpointer PVOID;
|
||||
typedef gpointer LPVOID;
|
||||
#ifndef __OS_H__
|
||||
typedef gboolean BOOL;
|
||||
#endif
|
||||
typedef guint32 *LPDWORD;
|
||||
typedef gint32 LONG;
|
||||
typedef guint32 ULONG;
|
||||
|
||||
@@ -10055,7 +10055,7 @@ typebuilder_setup_fields (MonoClass *klass)
|
||||
if (fb->def_value) {
|
||||
MonoDynamicImage *assembly = (MonoDynamicImage*)klass->image;
|
||||
field->type->attrs |= FIELD_ATTRIBUTE_HAS_DEFAULT;
|
||||
idx = encode_constant (assembly, fb->def_value, &klass->ext->field_def_values [i].def_type);
|
||||
idx = encode_constant (assembly, fb->def_value, (guint32 *) &klass->ext->field_def_values [i].def_type);
|
||||
/* Copy the data from the blob since it might get realloc-ed */
|
||||
p = assembly->blob.data + idx;
|
||||
len = mono_metadata_decode_blob_size (p, &p2);
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2009-04-03 Miguel de Icaza <[email protected]>
|
||||
|
||||
* mono-filemap.c: Move mono_file_unmap for the not-mmap case to
|
||||
the mono-filemap.c file so it can be plugged in platform-specific
|
||||
code as well.
|
||||
|
||||
2009-02-16 Mark Probst <[email protected]>
|
||||
|
||||
Contributed under the terms of the MIT/X11 license by Steven
|
||||
|
||||
@@ -50,12 +50,23 @@ mono_file_map_close (MonoFileMap *fmap)
|
||||
}
|
||||
|
||||
#if !defined(HAVE_MMAP) && !defined (PLATFORM_WIN32)
|
||||
|
||||
static mono_file_map_alloc_fn alloc_fn = (mono_file_map_alloc_fn) malloc;
|
||||
static mono_file_map_release_fn release_fn = (mono_file_map_release_fn) free;
|
||||
|
||||
void
|
||||
mono_file_map_set_allocator (mono_file_map_alloc_fn alloc, mono_file_map_release_fn release)
|
||||
{
|
||||
alloc_fn = alloc == NULL ? (mono_file_map_alloc_fn) malloc : alloc;
|
||||
release_fn = release == NULL ? (mono_file_map_release_fn) free : release;
|
||||
}
|
||||
|
||||
void *
|
||||
mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle)
|
||||
{
|
||||
guint64 cur_offset;
|
||||
size_t bytes_read;
|
||||
void *ptr = malloc (length);
|
||||
void *ptr = (*alloc_fn) (length);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
cur_offset = lseek (fd, 0, SEEK_CUR);
|
||||
@@ -68,4 +79,11 @@ mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_hand
|
||||
*ret_handle = NULL;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int
|
||||
mono_file_unmap (void *addr, void *handle)
|
||||
{
|
||||
(*release_fn) (addr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -409,13 +409,6 @@ mono_vfree (void *addr, size_t length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
mono_file_unmap (void *addr, void *handle)
|
||||
{
|
||||
free (addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
mono_mprotect (void *addr, size_t length, int flags)
|
||||
{
|
||||
|
||||
@@ -42,5 +42,15 @@ void* mono_shared_area_for_pid (void *pid);
|
||||
void mono_shared_area_unload (void *area);
|
||||
int mono_shared_area_instances (void **array, int count);
|
||||
|
||||
/*
|
||||
* On systems where we have to load code into memory instead of mmaping
|
||||
* we allow for the allocator to be set. This function is only
|
||||
* defined on those platforms.
|
||||
*/
|
||||
typedef void *(*mono_file_map_alloc_fn) (size_t length);
|
||||
typedef void (*mono_file_map_release_fn) (void *addr);
|
||||
|
||||
void mono_file_map_set_allocator (mono_file_map_alloc_fn alloc, mono_file_map_release_fn release);
|
||||
|
||||
#endif /* __MONO_UTILS_MMAP_H__ */
|
||||
|
||||
Reference in new issue
Block a user