void * initial_C_stack_pointer;
static char * reload_saved_string;
static unsigned int reload_saved_string_length;
+static bool reload_saved_legacy_p;
void *
obstack_chunk_alloc (size_t size)
if ((ARG_REF (1)) != SHARP_F)
{
CHECK_ARG (1, STRING_P);
- {
- unsigned int length = (STRING_LENGTH (ARG_REF (1)));
- if (length > 0)
- {
- reload_saved_string = (OS_malloc (length));
- reload_saved_string_length = length;
- {
- char * scan = (STRING_POINTER (ARG_REF (1)));
- char * end = (scan + length);
- char * scan_result = reload_saved_string;
- while (scan < end)
- (*scan_result++) = (*scan++);
- }
- }
- }
+ SCHEME_OBJECT string = (ARG_REF (1));
+ unsigned int length = (STRING_LENGTH (string));
+ if (length > 0)
+ {
+ reload_saved_legacy_p = (LEGACY_STRING_P (string));
+ reload_saved_string = (OS_malloc (length));
+ reload_saved_string_length = length;
+
+ memcpy (reload_saved_string, (STRING_POINTER (string)), length);
+ }
}
PRIMITIVE_RETURN (UNSPECIFIC);
}
PRIMITIVE_HEADER (0);
if (reload_saved_string == 0)
PRIMITIVE_RETURN (SHARP_F);
- {
- SCHEME_OBJECT result =
- (memory_to_string (reload_saved_string_length,
- ((unsigned char *) reload_saved_string)));
- free (reload_saved_string);
- reload_saved_string = 0;
- PRIMITIVE_RETURN (result);
- }
+
+ SCHEME_OBJECT result = reload_saved_legacy_p
+ ? (memory_to_string (reload_saved_string_length,
+ ((unsigned char *) reload_saved_string)))
+ : (memory_to_bytevector (reload_saved_string_length,
+ ((unsigned char *) reload_saved_string)));
+ free (reload_saved_string);
+ reload_saved_string = 0;
+ PRIMITIVE_RETURN (result);
}
DEFINE_PRIMITIVE ("BATCH-MODE?", Prim_batch_mode_p, 0, 0, 0)
#define BYTEVECTOR_POINTER(v) ((uint8_t *) (MEMORY_LOC ((v), BYTEVECTOR_DATA)))
-static uint8_t *
+uint8_t *
arg_bytevector (int n, unsigned long * len_r)
{
CHECK_ARG (n, BYTEVECTOR_P);
return (uint8_t) value;
}
-static SCHEME_OBJECT
+SCHEME_OBJECT
allocate_bytevector (unsigned long nbytes)
{
SCHEME_OBJECT result
return (result);
}
-static SCHEME_OBJECT
+SCHEME_OBJECT
memory_to_bytevector (unsigned long n_bytes, const void * vp)
{
SCHEME_OBJECT result = (allocate_bytevector (n_bytes));
extern SCHEME_OBJECT char_pointer_to_string (const char *);
extern SCHEME_OBJECT char_pointer_to_string_no_gc (const char *);
extern unsigned char * string_to_char_pointer (SCHEME_OBJECT, unsigned long *);
+extern uint8_t * arg_bytevector (int, unsigned long *);
+extern SCHEME_OBJECT allocate_bytevector (unsigned long);
+extern SCHEME_OBJECT memory_to_bytevector (unsigned long, const void *);
extern SCHEME_OBJECT allocate_bit_string (unsigned long);
extern const char * arg_symbol (int);
extern const char * arg_interned_symbol (int);