chunk: Add helper to copy a chunk left-padded to a certain length

This commit is contained in:
Tobias Brunner
2019-04-24 11:40:14 +02:00
parent c92eade82c
commit a5a8f2bce2
3 changed files with 70 additions and 2 deletions
+11 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008-2013 Tobias Brunner
* Copyright (C) 2008-2019 Tobias Brunner
* Copyright (C) 2005-2008 Martin Willi
* Copyright (C) 2005 Jan Hutter
* HSR Hochschule fuer Technik Rapperswil
@@ -292,6 +292,16 @@ static inline chunk_t chunk_skip_zero(chunk_t chunk)
return chunk;
}
/**
* Copy the data from src to dst, left-padded with chr if dst is longer,
* otherwise data is copied truncated on the left.
*
* @param dst data is copied here
* @param src data is copied from here
* @param chr value to use for padding if necessary
* @return the destination chunk
*/
chunk_t chunk_copy_pad(chunk_t dst, chunk_t src, u_char chr);
/**
* Compare two chunks, returns zero if a equals b