Skip to content

Commit

Permalink
Remove unused scratch_buffer_dupfree
Browse files Browse the repository at this point in the history
Turns out scratch_buffer_dupfree internal API was unused since

commit ef07000
stdlib: Simplify buffer management in canonicalize

And the related test in malloc/tst-scratch_buffer had issues
so it's better to remove it completely.

Reviewed-by: Florian Weimer <[email protected]>
  • Loading branch information
nsz-arm committed Oct 28, 2022
1 parent 2eeeee7 commit 8c77e26
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 79 deletions.
16 changes: 0 additions & 16 deletions include/scratch_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,4 @@ scratch_buffer_set_array_size (struct scratch_buffer *buffer,
(buffer, nelem, size));
}

/* Return a copy of *BUFFER's first SIZE bytes as a heap-allocated block,
deallocating *BUFFER if it was heap-allocated. SIZE must be at
most *BUFFER's size. Return NULL (setting errno) on memory
exhaustion. */
void *__libc_scratch_buffer_dupfree (struct scratch_buffer *buffer,
size_t size);
libc_hidden_proto (__libc_scratch_buffer_dupfree)

/* Alias for __libc_scratch_dupfree. */
static __always_inline void *
scratch_buffer_dupfree (struct scratch_buffer *buffer, size_t size)
{
void *r = __libc_scratch_buffer_dupfree (buffer, size);
return __glibc_likely (r != NULL) ? r : NULL;
}

#endif /* _SCRATCH_BUFFER_H */
1 change: 0 additions & 1 deletion malloc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ tests-mcheck = $(filter-out $(tests-exclude-mcheck) $(tests-static), $(tests))
endif

routines = malloc mcheck mtrace obstack reallocarray \
scratch_buffer_dupfree \
scratch_buffer_grow scratch_buffer_grow_preserve \
scratch_buffer_set_array_size \
dynarray_at_failure \
Expand Down
1 change: 0 additions & 1 deletion malloc/Versions
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ libc {
__libc_thread_freeres;

# struct scratch_buffer support
__libc_scratch_buffer_dupfree;
__libc_scratch_buffer_grow;
__libc_scratch_buffer_grow_preserve;
__libc_scratch_buffer_set_array_size;
Expand Down
41 changes: 0 additions & 41 deletions malloc/scratch_buffer_dupfree.c

This file was deleted.

20 changes: 0 additions & 20 deletions malloc/tst-scratch_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,6 @@ do_test (void)
&& array_size_must_fail (4, ((size_t)-1) / 4)))
return 1;
}
{
struct scratch_buffer buf;
scratch_buffer_init (&buf);
memset (buf.data, '@', buf.length);

size_t sizes[] = { 16, buf.length, buf.length + 16 };
for (int i = 0; i < array_length (sizes); i++)
{
/* The extra size is unitialized through realloc. */
size_t l = sizes[i] > buf.length ? sizes[i] : buf.length;
void *r = scratch_buffer_dupfree (&buf, l);
void *c = xmalloc (l);
memset (c, '@', l);
TEST_COMPARE_BLOB (r, l, buf.data, l);
free (r);
free (c);
}

scratch_buffer_free (&buf);
}
return 0;
}

Expand Down

0 comments on commit 8c77e26

Please sign in to comment.