@@ -38,33 +38,27 @@ LOG_MODULE_REGISTER(fast_get, CONFIG_SOF_LOG_LEVEL);
3838static int fast_get_realloc (struct sof_fast_get_data * data )
3939{
4040 struct sof_fast_get_entry * entries ;
41-
42- if (!data -> num_entries ) {
43- /*
44- * Allocate 8 entries for the beginning. Currently we only use
45- * 2 entries at most, so this should provide a reasonable first
46- * allocation.
47- */
48- const unsigned int n_entries = 8 ;
49-
50- data -> entries = rzalloc (SOF_MEM_ZONE_RUNTIME , 0 , SOF_MEM_CAPS_RAM ,
51- n_entries * sizeof (* entries ));
52- if (!data -> entries )
53- return - ENOMEM ;
54- data -> num_entries = n_entries ;
55- return 0 ;
56- }
57-
58- entries = rzalloc (SOF_MEM_ZONE_RUNTIME , 0 , SOF_MEM_CAPS_RAM ,
59- 2 * data -> num_entries * sizeof (* entries ));
41+ /*
42+ * Allocate 8 entries for the beginning. Currently we only use 2 entries
43+ * at most, so this should provide a reasonable first allocation.
44+ */
45+ const unsigned int init_n_entries = 8 ;
46+ unsigned int n_entries = data -> num_entries ? data -> num_entries * 2 : init_n_entries ;
47+
48+ entries = rzalloc (SOF_MEM_ZONE_RUNTIME_SHARED , SOF_MEM_FLAG_COHERENT , SOF_MEM_CAPS_RAM ,
49+ n_entries * sizeof (* entries ));
6050 if (!entries )
6151 return - ENOMEM ;
6252
63- memcpy_s (entries , 2 * data -> num_entries * sizeof (* entries ), data -> entries ,
64- data -> num_entries * sizeof (* entries ));
65- rfree (data -> entries );
53+ if (data -> num_entries ) {
54+ memcpy_s (entries , n_entries * sizeof (* entries ), data -> entries ,
55+ data -> num_entries * sizeof (* entries ));
56+ rfree (data -> entries );
57+ }
58+
6659 data -> entries = entries ;
67- data -> num_entries = 2 * data -> num_entries ;
60+ data -> num_entries = n_entries ;
61+
6862 return 0 ;
6963}
7064
0 commit comments