Skip to content

Commit a03ae80

Browse files
committed
refactor: Delete tox_memory, align on mem and os_memory.
os_memory will be os_mem later.
1 parent 4c88fed commit a03ae80

28 files changed

Lines changed: 81 additions & 268 deletions

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,6 @@ set(toxcore_SOURCES
358358
toxcore/tox_events.h
359359
toxcore/tox_log_level.c
360360
toxcore/tox_log_level.h
361-
toxcore/tox_memory.c
362-
toxcore/tox_memory.h
363-
toxcore/tox_memory_impl.h
364361
toxcore/tox_options.c
365362
toxcore/tox_options.h
366363
toxcore/tox_private.c

other/bootstrap_daemon/src/tox-bootstrapd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ int main(int argc, char *argv[])
290290
IP ip;
291291
ip_init(&ip, enable_ipv6);
292292

293-
const Tox_Memory *mem = os_memory();
293+
const Memory *mem = os_memory();
294294
const Tox_Random *rng = os_random();
295295
const Network *ns = os_network();
296296

testing/support/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ cc_library(
5050
"//c-toxcore/toxcore:network",
5151
"//c-toxcore/toxcore:tox",
5252
"//c-toxcore/toxcore:tox_events",
53-
"//c-toxcore/toxcore:tox_memory",
5453
"//c-toxcore/toxcore:tox_options",
5554
"//c-toxcore/toxcore:tox_random",
5655
"@psocket",

testing/support/doubles/fake_memory.hh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "../public/memory.hh"
88

99
// Forward declaration
10-
struct Tox_Memory;
10+
struct Memory;
1111

1212
namespace tox::test {
1313

@@ -30,9 +30,9 @@ public:
3030
void set_observer(Observer observer);
3131

3232
/**
33-
* @brief Returns C-compatible Tox_Memory struct.
33+
* @brief Returns C-compatible Memory struct.
3434
*/
35-
struct Tox_Memory c_memory() override;
35+
struct Memory c_memory() override;
3636

3737
size_t current_allocation() const;
3838
size_t max_allocation() const;

testing/support/public/memory.hh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <cstdint>
66

77
// Forward declaration
8-
struct Tox_Memory;
8+
struct Memory;
99

1010
namespace tox::test {
1111

@@ -21,9 +21,9 @@ public:
2121
virtual void free(void *ptr) = 0;
2222

2323
/**
24-
* @brief Returns C-compatible Tox_Memory struct.
24+
* @brief Returns C-compatible Memory struct.
2525
*/
26-
virtual struct Tox_Memory c_memory() = 0;
26+
virtual struct Memory c_memory() = 0;
2727
};
2828

2929
} // namespace tox::test

testing/support/public/simulated_environment.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <sys/socket.h>
1414
#endif
1515

16-
#include "../../../toxcore/tox_memory_impl.h"
16+
#include "../../../toxcore/mem.h"
1717
#include "../../../toxcore/tox_private.h"
1818
#include "../../../toxcore/tox_random_impl.h"
1919
#include "../doubles/fake_clock.hh"
@@ -34,7 +34,7 @@ struct ScopedToxSystem {
3434
// C structs
3535
struct Network c_network;
3636
struct Tox_Random c_random;
37-
struct Tox_Memory c_memory;
37+
struct Memory c_memory;
3838

3939
// The main struct passed to tox_new
4040
Tox_System system;

testing/support/public/simulation.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include <sys/socket.h>
1717
#endif
1818

19+
#include "../../../toxcore/mem.h"
1920
#include "../../../toxcore/tox.h"
20-
#include "../../../toxcore/tox_memory_impl.h"
2121
#include "../../../toxcore/tox_private.h"
2222
#include "../../../toxcore/tox_random_impl.h"
2323
#include "../doubles/fake_clock.hh"
@@ -172,7 +172,7 @@ private:
172172
public:
173173
struct Network c_network;
174174
struct Tox_Random c_random;
175-
struct Tox_Memory c_memory;
175+
struct Memory c_memory;
176176
struct IP ip;
177177
};
178178

testing/support/src/fake_memory.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#include <iostream>
55
#include <new>
66

7-
#include "../../../toxcore/tox_memory_impl.h"
7+
#include "../../../toxcore/mem.h"
88

99
namespace tox::test {
1010

1111
// --- Trampolines ---
1212

13-
static const Tox_Memory_Funcs kFakeMemoryVtable = {
13+
static const Memory_Funcs kFakeMemoryVtable = {
1414
.malloc_callback
1515
= [](void *obj, uint32_t size) { return static_cast<FakeMemory *>(obj)->malloc(size); },
1616
.realloc_callback
@@ -127,7 +127,7 @@ void FakeMemory::set_failure_injector(FailureInjector injector)
127127

128128
void FakeMemory::set_observer(Observer observer) { observer_ = std::move(observer); }
129129

130-
struct Tox_Memory FakeMemory::c_memory() { return Tox_Memory{&kFakeMemoryVtable, this}; }
130+
struct Memory FakeMemory::c_memory() { return Memory{&kFakeMemoryVtable, this}; }
131131

132132
size_t FakeMemory::current_allocation() const { return current_allocation_.load(); }
133133

toxav/toxav.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ typedef struct DecodeTimeStats {
8686
} DecodeTimeStats;
8787

8888
struct ToxAV {
89-
const struct Tox_Memory *mem;
89+
const struct Memory *mem;
9090
Logger *log;
9191
Tox *tox;
9292
MSISession *msi;

toxcore/BUILD.bazel

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,14 @@ cc_library(
5454
deps = [":attributes"],
5555
)
5656

57-
cc_library(
58-
name = "tox_memory",
59-
srcs = ["tox_memory.c"],
60-
hdrs = [
61-
"tox_memory.h",
62-
"tox_memory_impl.h",
63-
],
64-
visibility = ["//c-toxcore:__subpackages__"],
65-
deps = [
66-
":ccompat",
67-
":tox_attributes",
68-
],
69-
)
70-
7157
cc_library(
7258
name = "os_memory",
7359
srcs = ["os_memory.c"],
7460
hdrs = ["os_memory.h"],
7561
visibility = ["//c-toxcore:__subpackages__"],
7662
deps = [
7763
":attributes",
78-
":tox_memory",
64+
":mem",
7965
],
8066
)
8167

@@ -89,8 +75,8 @@ cc_library(
8975
visibility = ["//c-toxcore:__subpackages__"],
9076
deps = [
9177
":ccompat",
78+
":mem",
9279
":tox_attributes",
93-
":tox_memory",
9480
],
9581
)
9682

@@ -115,7 +101,6 @@ cc_library(
115101
deps = [
116102
":attributes",
117103
":ccompat",
118-
":tox_memory",
119104
],
120105
)
121106

0 commit comments

Comments
 (0)