Commit 4c743a68 authored by Daniel Salzman's avatar Daniel Salzman

contrib: move string from internal mem

parent a04479c3
......@@ -26,6 +26,7 @@ libcontrib_ladir = $(includedir)
nobase_libcontrib_la_HEADERS = \
contrib/endian.h \
contrib/getline.h \
contrib/string.h \
contrib/openbsd/strlcat.h \
contrib/openbsd/strlcpy.h \
contrib/ucw/array-sort.h \
......@@ -78,7 +79,6 @@ nobase_libknot_internal_la_HEADERS = \
libknot/internal/hhash.h \
libknot/internal/lists.h \
libknot/internal/macros.h \
libknot/internal/mem.h \
libknot/internal/mempattern.h \
libknot/internal/namedb/namedb.h \
libknot/internal/namedb/namedb_lmdb.h \
......@@ -102,6 +102,7 @@ nobase_libknot_yparser_la_HEADERS = \
# dynamic: libknot sources
libcontrib_la_SOURCES = \
contrib/getline.c \
contrib/string.c \
contrib/openbsd/strlcat.c \
contrib/openbsd/strlcpy.c \
contrib/ucw/heap.c \
......@@ -148,7 +149,6 @@ libknot_internal_la_SOURCES = \
libknot/internal/errcode.c \
libknot/internal/hhash.c \
libknot/internal/lists.c \
libknot/internal/mem.c \
libknot/internal/mempattern.c \
libknot/internal/namedb/namedb_lmdb.c \
libknot/internal/namedb/namedb_trie.c \
......
......@@ -20,9 +20,9 @@
#include <stdlib.h>
#include <string.h>
#include "libknot/internal/mem.h"
#include "contrib/string.h"
uint8_t *knot_memdup(const uint8_t *data, size_t data_size)
uint8_t *memdup(const uint8_t *data, size_t data_size)
{
uint8_t *result = (uint8_t *)malloc(data_size);
if (!result) {
......
......@@ -13,6 +13,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file
*
* \brief String manipulations.
*
* \addtogroup contrib
* @{
*/
#pragma once
......@@ -23,7 +31,7 @@
*
* Like \c strdup, but for binary data.
*/
uint8_t *knot_memdup(const uint8_t *data, size_t data_size);
uint8_t *memdup(const uint8_t *data, size_t data_size);
/*!
* \brief Format string and take care of allocating memory.
......@@ -52,3 +60,5 @@ char *strcdup(const char *s1, const char *s2);
* \return Newly allocated string, NULL in case of error.
*/
char *strstrip(const char *str);
/*! @} */
......@@ -26,10 +26,10 @@
#include "knot/common/log.h"
#include "knot/nameserver/query_module.h"
#include "knot/nameserver/internet.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/sockaddr.h"
#include "libknot/yparser/ypformat.h"
#include "libknot/yparser/yptrafo.h"
#include "contrib/string.h"
#include "contrib/ucw/mempool.h"
// The active configuration.
......
......@@ -24,9 +24,9 @@
#include "knot/server/dthreads.h"
#include "libknot/libknot.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/sockaddr.h"
#include "libknot/yparser/yptrafo.h"
#include "contrib/string.h"
#include "contrib/openbsd/strlcat.h"
/*! Configuration specific logging. */
......
......@@ -21,7 +21,7 @@
#include "knot/conf/confio.h"
#include "knot/conf/tools.h"
#include "libknot/yparser/yptrafo.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "contrib/openbsd/strlcat.h"
#define FCN(io) (io->fcn != NULL) ? io->fcn(io) : KNOT_EOK
......
......@@ -17,12 +17,12 @@
#include <assert.h>
#include "knot/ctl/estimator.h"
#include "knot/zone/node.h"
#include "libknot/dname.h"
#include "libknot/internal/lists.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/macros.h"
#include "knot/zone/node.h"
#include "libknot/descriptor.h"
#include "contrib/string.h"
// Addition constants used for tweaking, mostly malloc overhead
enum estim_consts {
......
......@@ -26,7 +26,7 @@
#endif
#include "dnssec/crypto.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "libknot/internal/macros.h"
#include "libknot/libknot.h"
#include "knot/common/log.h"
......
......@@ -31,9 +31,9 @@
#include "knot/zone/timers.h"
#include "libknot/libknot.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/net.h"
#include "libknot/yparser/yptrafo.h"
#include "contrib/string.h"
#include "contrib/openbsd/strlcpy.h"
#define KNOT_CTL_REALM "knot."
......
......@@ -20,7 +20,7 @@
#include "dnssec/error.h"
#include "dnssec/event.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "libknot/libknot.h"
#include "knot/conf/conf.h"
#include "knot/common/log.h"
......
......@@ -25,7 +25,7 @@
#include "libknot/dname.h"
#include "libknot/dnssec/rrset-sign.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "dnssec/error.h"
#include "dnssec/kasp.h"
......
......@@ -22,7 +22,7 @@
#include "knot/modules/rosedb.c"
#include "zscanner/scanner.h"
#include "libknot/libknot.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
static int rosedb_add(struct cache *cache, MDB_txn *txn, int argc, char *argv[]);
static int rosedb_del(struct cache *cache, MDB_txn *txn, int argc, char *argv[]);
......
......@@ -17,7 +17,7 @@
#include "libknot/dname.h"
#include "libknot/internal/namedb/namedb.h"
#include "libknot/internal/namedb/namedb_lmdb.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "libknot/internal/wire_ctx.h"
#include "knot/zone/timers.h"
#include "knot/zone/zonedb.h"
......
......@@ -38,7 +38,7 @@
#include "libknot/libknot.h"
#include "libknot/dname.h"
#include "libknot/internal/utils.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "libknot/rrtype/soa.h"
#define JOURNAL_SUFFIX ".diff.db"
......
......@@ -27,7 +27,7 @@
#include "libknot/libknot.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "knot/common/log.h"
#include "knot/dnssec/zone-nsec.h"
#include "knot/zone/semantic-check.h"
......
......@@ -20,8 +20,8 @@
#include "libknot/binary.h"
#include "libknot/errcode.h"
#include "libknot/internal/base64.h"
#include "libknot/internal/mem.h"
#include "libknot/internal/macros.h"
#include "contrib/string.h"
_public_
int knot_binary_from_base64(const char *base64, knot_binary_t *to)
......@@ -51,7 +51,7 @@ int knot_binary_from_string(const uint8_t *data, size_t size, knot_binary_t *to)
return KNOT_EINVAL;
}
uint8_t *copy = knot_memdup(data, size);
uint8_t *copy = memdup(data, size);
if (!copy) {
return KNOT_ENOMEM;
}
......
......@@ -17,7 +17,7 @@
#include "libknot/rrtype/nsec3param.h"
#include "libknot/errcode.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
_public_
int knot_nsec3param_from_wire(knot_nsec3_params_t *params,
......@@ -35,8 +35,7 @@ int knot_nsec3param_from_wire(knot_nsec3_params_t *params,
result.salt_length = knot_nsec3param_salt_length(rrs, 0);
if (result.salt_length > 0) {
result.salt = knot_memdup(knot_nsec3param_salt(rrs, 0),
result.salt_length);
result.salt = memdup(knot_nsec3param_salt(rrs, 0), result.salt_length);
if (!result.salt) {
return KNOT_ENOMEM;
}
......
......@@ -18,10 +18,10 @@
#include <string.h>
#include "contrib/getline.h"
#include "contrib/string.h"
#include "dnssec/error.h"
#include "libknot/errcode.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/mem.h"
#include "libknot/tsig.h"
_public_
......
......@@ -22,7 +22,7 @@
#include "utils/knot1to2/extra.h"
#include "utils/knot1to2/scheme.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "libknot/internal/trie/hat-trie.h"
#define KNOT1TO2_VERSION "knot1to2, version " PACKAGE_VERSION "\n"
......
......@@ -33,7 +33,7 @@
#include "utils/common/token.h"
#include "libknot/libknot.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "contrib/openbsd/strlcpy.h"
/* Declarations of cmd parse functions. */
......
......@@ -20,7 +20,7 @@
#include "knot/conf/confio.h"
#include "knot/conf/tools.h"
#include "knot/ctl/remote.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "contrib/openbsd/strlcat.h"
#define SKIP_OPENBSD skip("Nested transactions are not supported on OpenBSD");
......
......@@ -20,7 +20,7 @@
#include "libknot/internal/trie/hat-trie.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
/* UCW array sorting defines. */
#define ASORT_PREFIX(X) str_key_##X
......
......@@ -18,7 +18,7 @@
#include <stdlib.h>
#include "libknot/internal/mem.h"
#include "contrib/string.h"
static void test_strstrip(void)
{
......
......@@ -23,7 +23,7 @@
#include <assert.h>
#include <tap/basic.h>
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "libknot/internal/namedb/namedb_lmdb.h"
#include "libknot/internal/namedb/namedb_trie.h"
#include "libknot/libknot.h"
......
......@@ -21,7 +21,7 @@
#include "libknot/internal/namedb/namedb.h"
#include "libknot/internal/namedb/namedb_lmdb.h"
#include "libknot/internal/mem.h"
#include "contrib/string.h"
#include "libknot/libknot.h"
#include "knot/zone/timers.h"
#include "knot/zone/zone.h"
......
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