Skip to content

Commit

Permalink
lib: make dlist<dlistString> work correctly
Browse files Browse the repository at this point in the history
This patch does some refactoring on dlistString to make it work
correctly with the new and type-safe dlist.
  • Loading branch information
arogge committed Feb 24, 2022
1 parent 0be6f81 commit 703f965
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions core/src/lib/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2021 Bareos GmbH & Co. KG
# Copyright (C) 2017-2022 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -58,7 +58,7 @@ set(BAREOS_SRCS
crypto_wrap.cc
daemon.cc
devlock.cc
dlist.cc
dlist_string.cc
edit.cc
fnmatch.cc
guid_to_name.cc
Expand Down
11 changes: 3 additions & 8 deletions core/src/lib/dlink.h
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2004-2010 Free Software Foundation Europe e.V.
Copyright (C) 2016-2021 Bareos GmbH & Co. KG
Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -24,13 +24,8 @@
#define BAREOS_LIB_DLINK_H_

template <typename T> struct dlink {
T* next;
T* prev;
dlink()
{
next = nullptr;
prev = nullptr;
}
T* next{nullptr};
T* prev{nullptr};
};

#endif // BAREOS_LIB_DLINK_H_
5 changes: 3 additions & 2 deletions core/src/lib/dlist.cc → core/src/lib/dlist_string.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2003-2011 Free Software Foundation Europe e.V.
Copyright (C) 2013-2021 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -28,6 +28,7 @@
*/

#include "lib/dlist.h"
#include "lib/dlist_string.h"

/* String helpers for dlist usage */

Expand All @@ -39,7 +40,7 @@ dlistString* new_dlistString(const char* str)
dlistString* new_dlistString(const char* str, int len)
{
dlistString* node;
node = (dlistString*)malloc(sizeof(dlink<char*>) + len + 1);
node = (dlistString*)malloc(sizeof(dlistString) + len);
bstrncpy(node->c_str(), str, len + 1);
return node;
}
2 changes: 1 addition & 1 deletion core/src/lib/dlist_string.h
Expand Up @@ -35,7 +35,7 @@ class dlistString {
public:
char* c_str() { return str_; }

dlink<char> link;
dlink<dlistString> link;

private:
char str_[1];
Expand Down

0 comments on commit 703f965

Please sign in to comment.