Commit 29b57291 authored by Jan Včelák's avatar Jan Včelák 🚀

[dnssec] remove unused dnssec_binary_ltrim

parent 011c7f1a
......@@ -140,28 +140,6 @@ int dnssec_binary_cmp(const dnssec_binary_t *one, const dnssec_binary_t *two)
}
}
_public_
void dnssec_binary_ltrim(dnssec_binary_t *binary)
{
if (!binary || !binary->data) {
return;
}
size_t start = 0;
while (start + 1 < binary->size && binary->data[start] == 0x00) {
start += 1;
}
if (start == 0) {
return;
}
size_t new_size = binary->size - start;
memmove(binary->data, binary->data + start, new_size);
binary->size = new_size;
}
_public_
int dnssec_binary_from_base64(const dnssec_binary_t *base64,
dnssec_binary_t *binary)
......
......@@ -111,15 +111,6 @@ int dnssec_binary_resize(dnssec_binary_t *data, size_t new_size);
*/
int dnssec_binary_cmp(const dnssec_binary_t *one, const dnssec_binary_t *two);
/*!
* Trim leading zeroes from the binary data.
*
* If the input are zeroes only, the last zero will be preserved.
*
* \param binary Input to be trimmed.
*/
void dnssec_binary_ltrim(dnssec_binary_t *binary);
/*!
* Allocate binary from Base64 encoded string.
*
......
......@@ -82,35 +82,12 @@ static void test_dup(void)
dnssec_binary_free(&dst);
}
static void test_ltrim(void)
{
dnssec_binary_t trim_me = {
.size = 4,
.data = (uint8_t []) { 0x02, 0x00, 0x01, 0x00 }
};
dnssec_binary_ltrim(&trim_me);
ok(trim_me.size == 4 && trim_me.data[0] == 0x02,
"dnssec_binary_ltrim() nothing to trim");
trim_me.data[0] = 0x00;
dnssec_binary_ltrim(&trim_me);
ok(trim_me.size == 2 && trim_me.data[0] == 0x01,
"dnssec_binary_ltrim() trim a few");
trim_me.data[0] = 0x00;
dnssec_binary_ltrim(&trim_me);
ok(trim_me.size == 1 && trim_me.data[0] == 0x00,
"dnssec_binary_ltrim() preserve last zero");
}
int main(void)
{
plan_lazy();
test_base64();
test_dup();
test_ltrim();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment