@@ -32,7 +32,6 @@ use std::ascii::AsciiExt;
32
32
use std:: cell:: RefCell ;
33
33
use std:: collections:: { HashMap , VecDeque } ;
34
34
use std:: default:: Default ;
35
- use std:: ffi:: CString ;
36
35
use std:: fmt:: { self , Write } ;
37
36
use std:: str;
38
37
use syntax:: feature_gate:: UnstableFeatures ;
@@ -529,8 +528,8 @@ extern {
529
528
fn hoedown_document_free ( md : * mut hoedown_document ) ;
530
529
531
530
fn hoedown_buffer_new ( unit : libc:: size_t ) -> * mut hoedown_buffer ;
532
- fn hoedown_buffer_puts ( b : * mut hoedown_buffer , c : * const libc:: c_char ) ;
533
531
fn hoedown_buffer_free ( b : * mut hoedown_buffer ) ;
532
+ fn hoedown_buffer_put ( b : * mut hoedown_buffer , c : * const u8 , len : libc:: size_t ) ;
534
533
}
535
534
536
535
impl hoedown_buffer {
@@ -620,8 +619,7 @@ pub fn render(w: &mut fmt::Formatter,
620
619
Some ( "rust-example-rendered" ) ,
621
620
None ,
622
621
playground_button. as_ref ( ) . map ( String :: as_str) ) ) ;
623
- let output = CString :: new ( s) . unwrap ( ) ;
624
- hoedown_buffer_puts ( ob, output. as_ptr ( ) ) ;
622
+ hoedown_buffer_put ( ob, s. as_ptr ( ) , s. len ( ) ) ;
625
623
} )
626
624
}
627
625
}
@@ -630,7 +628,7 @@ pub fn render(w: &mut fmt::Formatter,
630
628
level : libc:: c_int , data : * const hoedown_renderer_data ,
631
629
_: libc:: size_t ) {
632
630
// hoedown does this, we may as well too
633
- unsafe { hoedown_buffer_puts ( ob, "\n \0 " . as_ptr ( ) as * const _ ) ; }
631
+ unsafe { hoedown_buffer_put ( ob, "\n " . as_ptr ( ) , 1 ) ; }
634
632
635
633
// Extract the text provided
636
634
let s = if text. is_null ( ) {
@@ -681,8 +679,7 @@ pub fn render(w: &mut fmt::Formatter,
681
679
<a href='#{id}'>{sec}{}</a></h{lvl}>",
682
680
s, lvl = level, id = id, sec = sec) ;
683
681
684
- let text = CString :: new ( text) . unwrap ( ) ;
685
- unsafe { hoedown_buffer_puts ( ob, text. as_ptr ( ) ) }
682
+ unsafe { hoedown_buffer_put ( ob, text. as_ptr ( ) , text. len ( ) ) ; }
686
683
}
687
684
688
685
extern fn codespan (
@@ -700,8 +697,9 @@ pub fn render(w: &mut fmt::Formatter,
700
697
} ;
701
698
702
699
let content = format ! ( "<code>{}</code>" , Escape ( & content) ) ;
703
- let element = CString :: new ( content) . unwrap ( ) ;
704
- unsafe { hoedown_buffer_puts ( ob, element. as_ptr ( ) ) ; }
700
+ unsafe {
701
+ hoedown_buffer_put ( ob, content. as_ptr ( ) , content. len ( ) ) ;
702
+ }
705
703
// Return anything except 0, which would mean "also print the code span verbatim".
706
704
1
707
705
}
0 commit comments