Commit Graph

23 Commits

Author SHA1 Message Date
iphydf
73484d8995 cleanup: Use calloc instead of malloc for struct allocations.
`malloc` is used only for byte/int arrays. Also, we no longer allow plain
`void *` allocations. Every allocation should have a real value type.
2022-01-09 22:42:50 +00:00
iphydf
f49168e209 chore: Make all function comments doxygen style /** comments.
This way, they become eligible for the tokstyle comment sync check.
2021-12-22 10:48:53 +00:00
iphydf
fd32c87707 cleanup: Don't include "config.h" unless needed.
Currently only `crypto_core_mem.c` needs this. We should try not to
depend on configure'd values. Also note: config.h is only created and
used in the autotools build. In CMake, we pass `-D` flags directly.
2021-12-12 22:18:38 +00:00
iphydf
2570ddcb17 Fix errors on error paths found by oomer.
* Use-after-free because we free network before dht in one case.
* Various unchecked allocs in tests (not so important).
* We used to not check whether ping arrays were actually allocated in DHT.
* `ping_kill` and `ping_array_kill` used to crash when passing NULL.

Also:
* Added an assert in all public API functions to ensure tox isn't NULL.
  The error message you get from that is a bit nicer than "Segmentation
  fault" when clients (or our tests) do things wrong.
* Decreased the sleep time in iterate_all_wait from 20ms to 5ms.
  Everything seems to still work with 5ms, and this greatly decreases
  the amount of time spent per test run, making oomer run much faster.
2020-05-02 21:47:08 +01:00
iphydf
11ad5471b9 Use spdx license identifier instead of GPL blurb. 2020-03-14 13:06:19 +00:00
iphydf
473cde24d8 Update copyright to 2018. 2018-08-26 18:57:29 +00:00
iphydf
a1035cf814 Add some tests for ping_array.
No timeout test here yet, because we don't yet have the ability to
manipulate time at will, so we would have to actually sleep.
2018-08-26 17:32:19 +00:00
iphydf
d6d305feeb Use per-instance Mono_Time for Messenger and onion. 2018-08-16 21:01:43 +00:00
iphydf
abc17b0f89 Factor out time keeping code into its own module: mono_time.c.
It turns out, `unix_time` is also monotonic, and is used as such, so I've
renamed the new functions to `mono_time_*`.

2018-07-08:
```
00:01 <@irungentoo> the idea used to be that the unix_time() function
  could go backward in time but I think I might have started using it like
  if it could not after I changed it so that it would never go back in time
```
2018-07-09 21:04:50 +00:00
iphydf
2b49f80395 Rename BS_LIST to BS_List to follow the naming conventions.
`BS_LIST` would be a constant. `BS_List` is a type name.
2018-07-08 19:03:52 +00:00
iphydf
be797d4b03 Move system header includes from network.h to network.c 2018-05-20 15:42:42 +00:00
iphydf
92ffad1a72 Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
2018-01-30 23:35:50 +00:00
iphydf
da739a9438 Add random_u16 function and rename the others to match. 2018-01-14 21:08:02 +00:00
iphydf
e775b5533b Make Ping_Array a module-private type. 2018-01-13 23:55:08 +00:00
iphydf
8f96ca6d86 Update license headers and remove redundant file name comment.
"All rights reserved" was incorrect. The project was licensed under GPL3,
which means a lot of rights are licensed to everybody in the world, i.e.
not reserved to the "Tox Project".
2017-01-19 00:01:44 +00:00
iphydf
15cb426166 Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
2016-09-24 21:53:50 +01:00
iphydf
0aa2840164 Group #include directives in 3-4 groups.
1. Current module (if C file).
2. Headers from current library.
3. Headers from other library (e.g. toxcore includes in toxav).
4. System headers.
2016-09-13 00:32:02 +01:00
iphydf
77db27331e Sort #includes in all source files. 2016-09-01 16:35:46 +01:00
iphydf
633da98ae6 Add braces to all if statements. 2016-08-31 20:04:16 +01:00
kyle condon
a13bc5e70c Update ping_array.c
Change calloc call on line 138 from empty_array->entries = calloc(size * sizeof(Ping_Array_Entry), 1);, to empty_array->entries = calloc(size, sizeof(Ping_Array_Entry));
2014-07-06 09:55:46 +01:00
Marc Schütz
99d5940140 Const correctness in various interdependent files 2014-06-10 20:54:48 +02:00
irungentoo
5b58da35f9 Fixed segfault. 2014-05-12 19:48:19 -04:00
irungentoo
10da970e0d Added ping_array, a special efficient array for use in operations
that require sending ping type packets.

Made ping packets use it.
2014-05-12 14:07:03 -04:00