Răsfoiți Sursa

fixes for unused references

Nicolas Cannasse 9 ani în urmă
părinte
comite
cf2042b59c
3 a modificat fișierele cu 5 adăugiri și 5 ștergeri
  1. 3 3
      src/std/file.c
  2. 1 1
      src/std/regexp.c
  3. 1 1
      src/std/string.c

+ 3 - 3
src/std/file.c

@@ -120,10 +120,10 @@ HL_PRIM vbyte *hl_file_contents( vbyte *name, int *size ) {
 		return NULL;
 	fseek(f,0,SEEK_END);
 	len = ftell(f);
-	*size = len;
+	if( size ) *size = len;
 	fseek(f,0,SEEK_SET);
-	content = (vbyte*)hl_gc_alloc_noptr(len+1);
-	content[len] = 0; // final 0 for UTF8
+	content = (vbyte*)hl_gc_alloc_noptr(size ? len : len+1);
+	if( !size ) content[len] = 0; // final 0 for UTF8
 	while( len > 0 ) {
 		int d = (int)fread((char*)content + p,1,len,f);
 		if( d <= 0 ) {

+ 1 - 1
src/std/regexp.c

@@ -98,7 +98,7 @@ HL_PRIM int hl_regexp_matched_pos( ereg *e, int m, int *len ) {
 	if( m < 0 || m >= e->nmatches )
 		hl_error_msg(USTR("Matched index %d outside bounds"),m);
 	start = e->matches[m*2];
-	*len = e->matches[m*2+1] - start;
+	if( len ) *len = e->matches[m*2+1] - start;
 	return start;
 }
 

+ 1 - 1
src/std/string.c

@@ -206,7 +206,7 @@ HL_PRIM vbyte *hl_utf16_to_utf8( vbyte *str, int pos, int *size ) {
 		}
 		c++;
 	}
-	*size = utf8bytes;
+	if( size ) *size = utf8bytes;
 	return out;
 }