File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -87,16 +87,19 @@ macro_rules! redis_module {
8787 _argv: * mut * mut raw:: RedisModuleString ,
8888 _argc: c_int,
8989 ) -> c_int {
90+
91+ // We use a statically sized buffer to avoid allocating.
92+ // This is needed since we use a custom allocator that relies on the Redis allocator,
93+ // which isn't yet ready at this point.
9094 let mut name_buffer = [ 0 ; 64 ] ;
91- let mut dest = name_buffer . as_mut_ptr ( ) ;
92- for byte in $module_name . chars ( ) {
93- unsafe {
94- * dest = byte as i8 ;
95- dest = dest . add ( 1 ) ;
96- }
95+ unsafe {
96+ std :: ptr :: copy (
97+ $module_name . as_ptr ( ) ,
98+ name_buffer . as_mut_ptr ( ) ,
99+ $module_name . len ( ) ,
100+ ) ;
97101 }
98- // We use an explicit block here to make sure all memory allocated before we
99- // switch to the Redis allocator will be out of scope and thus deallocated.
102+
100103 let module_version = $module_version as c_int;
101104
102105 if unsafe { raw:: Export_RedisModule_Init (
You can’t perform that action at this time.
0 commit comments