Added const keywords wherever I could find a reasonable place

to improve error detection and efficiency.
This commit is contained in:
shivers 1995-10-22 12:29:54 +00:00
parent 1d62cb2182
commit bd33154d9a
2 changed files with 9 additions and 10 deletions

View File

@ -20,4 +20,4 @@ extern char *copystring(char *, const char *);
extern scheme_value strlen_or_false(const char *);
extern void cig_check_nargs(int arity, int nargs, char *fn);
extern void cig_check_nargs(int arity, int nargs, const char *fn);

View File

@ -17,7 +17,7 @@
** If C string is NULL, do nothing and return #f.
*/
int c2scheme_strcpy(scheme_value sstr, char *cstr)
int c2scheme_strcpy(scheme_value sstr, const char *cstr)
{
if( cstr ) {
strncpy( (char*) StobData(sstr), cstr, STRING_LENGTH(sstr) );
@ -28,7 +28,7 @@ int c2scheme_strcpy(scheme_value sstr, char *cstr)
/* Same as above, but free the C string when we are done. */
int c2scheme_strcpy_free(scheme_value sstr, char *cstr)
int c2scheme_strcpy_free(scheme_value sstr, const char *cstr)
{
if( cstr ) {
strncpy( (char*) StobData(sstr), cstr, STRING_LENGTH(sstr) );
@ -42,11 +42,10 @@ char *scheme2c_strcpy(scheme_value sstr)
{
char *result;
int slen;
extern void *memcpy(void*, const void*, size_t);
extern int errno;
slen = STRING_LENGTH(sstr);
result = (char*) malloc(slen+1);
result = Malloc(char, slen+1);
if( result == NULL ) {
fprintf(stderr,
@ -56,7 +55,7 @@ char *scheme2c_strcpy(scheme_value sstr)
exit(-1);
}
memcpy(result, (void *) cig_string_body(sstr), slen);
memcpy(result, cig_string_body(sstr), slen);
result[slen] = '\000';
return result;
}
@ -66,9 +65,9 @@ char *scheme2c_strcpy(scheme_value sstr)
** The terminating null is not counted. Returns #f on NULL.
*/
scheme_value c_veclen(long *vec)
scheme_value c_veclen(const long *vec)
{
long *vptr = vec;
const long *vptr = vec;
if( !vptr ) return SCHFALSE;
while( *vptr ) vptr++;
return ENTER_FIXNUM(vptr - vec);
@ -112,7 +111,7 @@ char *copystring_or_die(const char *str ) /* Note: NULL -> NULL. */
else return NULL;
}
int cstring_nullp( char *s ) { return ! s; }
int cstring_nullp( const char *s ) { return ! s; }
scheme_value strlen_or_false(const char *s)
{ return s ? ENTER_FIXNUM(strlen(s)) : SCHFALSE; }
@ -138,7 +137,7 @@ void set_strvec_carriers(scheme_value svec, char const * const * cvec)
}
/* Helper function for arg checking. Why bother, actually? */
void cig_check_nargs(int arity, int nargs, char *fn)
void cig_check_nargs(int arity, int nargs, const char *fn)
{
if( arity != nargs ) {
fprintf(stderr,