Skip to content

Commit 41c0708

Browse files
committed
alloc.h: remove rbrealloc() and rbrealloc_align()
These interfaces are no longer used anywhere, so they can be safely removed. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 85c117d commit 41c0708

6 files changed

Lines changed: 0 additions & 104 deletions

File tree

posix/include/rtos/alloc.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,6 @@ static inline void *rballoc(uint32_t flags, size_t bytes)
9797
return rballoc_align(flags, bytes, PLATFORM_DCACHE_ALIGN);
9898
}
9999

100-
/**
101-
* Changes size of the memory block allocated.
102-
* @param ptr Address of the block to resize.
103-
* @param flags Flags, see SOF_MEM_FLAG_...
104-
* @param bytes New size in bytes.
105-
* @param old_bytes Old size in bytes.
106-
* @param alignment Alignment in bytes.
107-
* @return Pointer to the resized memory of NULL if failed.
108-
*/
109-
void *rbrealloc_align(void *ptr, uint32_t flags, size_t bytes,
110-
size_t old_bytes, uint32_t alignment);
111-
112-
/**
113-
* Similar to rballoc_align(), returns resized buffer aligned to
114-
* PLATFORM_DCACHE_ALIGN.
115-
*/
116-
static inline void *rbrealloc(void *ptr, uint32_t flags,
117-
size_t bytes, size_t old_bytes)
118-
{
119-
return rbrealloc_align(ptr, flags, bytes, old_bytes,
120-
PLATFORM_DCACHE_ALIGN);
121-
}
122-
123100
/**
124101
* Frees the memory block.
125102
* @param ptr Pointer to the memory block.

src/lib/alloc.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ void rfree(void *ptr)
3838
free(ptr);
3939
}
4040

41-
void *rbrealloc_align(void *ptr, uint32_t flags, size_t bytes,
42-
size_t old_bytes, uint32_t alignment)
43-
{
44-
void *newptr = aligned_alloc(alignment, bytes);
45-
46-
if (!newptr)
47-
return NULL;
48-
memcpy(newptr, ptr, bytes > old_bytes ? old_bytes : bytes);
49-
free(ptr);
50-
return newptr;
51-
}
52-
5341
/* TODO: all mm_pm_...() routines to be implemented for IMR storage */
5442
uint32_t mm_pm_context_size(void)
5543
{

src/platform/library/lib/alloc.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ void *rballoc_align(uint32_t flags, size_t bytes,
4242
return malloc(bytes);
4343
}
4444

45-
void *rbrealloc_align(void *ptr, uint32_t flags, size_t bytes,
46-
size_t old_bytes, uint32_t alignment)
47-
{
48-
return realloc(ptr, bytes);
49-
}
50-
5145
void *sof_heap_alloc(struct k_heap *heap, uint32_t flags, size_t bytes,
5246
size_t alignment)
5347
{

test/cmocka/src/common_mocks.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ void WEAK *rzalloc(uint32_t flags,
5959
return calloc(bytes, 1);
6060
}
6161

62-
void WEAK *rbrealloc_align(void *ptr, uint32_t flags,
63-
size_t bytes, size_t old_bytes, uint32_t alignment)
64-
{
65-
(void)flags;
66-
(void)old_bytes;
67-
(void)alignment;
68-
69-
return realloc(ptr, bytes);
70-
}
71-
7262
void WEAK *rmalloc_align(uint32_t flags, size_t bytes, uint32_t alignment)
7363
{
7464
(void)flags;

zephyr/include/rtos/alloc.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,6 @@ static inline void *rballoc(uint32_t flags, size_t bytes)
8888
return rballoc_align(flags, bytes, PLATFORM_DCACHE_ALIGN);
8989
}
9090

91-
/**
92-
* Changes size of the memory block allocated.
93-
* @param ptr Address of the block to resize.
94-
* @param flags Flags, see SOF_MEM_FLAG_...
95-
* @param bytes New size in bytes.
96-
* @param old_bytes Old size in bytes.
97-
* @param alignment Alignment in bytes.
98-
* @return Pointer to the resized memory of NULL if failed.
99-
*/
100-
void *rbrealloc_align(void *ptr, uint32_t flags, size_t bytes,
101-
size_t old_bytes, uint32_t alignment);
102-
103-
/**
104-
* Similar to rballoc_align(), returns resized buffer aligned to
105-
* PLATFORM_DCACHE_ALIGN.
106-
*/
107-
static inline void *rbrealloc(void *ptr, uint32_t flags,
108-
size_t bytes, size_t old_bytes)
109-
{
110-
return rbrealloc_align(ptr, flags, bytes, old_bytes,
111-
PLATFORM_DCACHE_ALIGN);
112-
}
113-
11491
/**
11592
* Frees the memory block.
11693
* @param ptr Pointer to the memory block.

zephyr/lib/alloc.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -493,36 +493,6 @@ void *rmalloc(uint32_t flags, size_t bytes)
493493
}
494494
EXPORT_SYMBOL(rmalloc);
495495

496-
void *rbrealloc_align(void *ptr, uint32_t flags, size_t bytes,
497-
size_t old_bytes, uint32_t alignment)
498-
{
499-
void *new_ptr;
500-
501-
if (!ptr) {
502-
return rballoc_align(flags, bytes, alignment);
503-
}
504-
505-
/* Original version returns NULL without freeing this memory */
506-
if (!bytes) {
507-
/* TODO: Should we call rfree(ptr); */
508-
tr_err(&zephyr_tr, "realloc failed for 0 bytes");
509-
return NULL;
510-
}
511-
512-
new_ptr = rballoc_align(flags, bytes, alignment);
513-
if (!new_ptr)
514-
return NULL;
515-
516-
if (!(flags & SOF_MEM_FLAG_NO_COPY))
517-
memcpy_s(new_ptr, bytes, ptr, MIN(bytes, old_bytes));
518-
519-
rfree(ptr);
520-
521-
tr_info(&zephyr_tr, "rbealloc: new ptr %p", new_ptr);
522-
523-
return new_ptr;
524-
}
525-
526496
/**
527497
* Similar to rmalloc(), guarantees that returned block is zeroed.
528498
*/

0 commit comments

Comments
 (0)