Skip to content
Permalink
Browse files

cleanup

Overview:
- Remove unnecesary 'const' on integers
- Remove unnecesary undef's
- Copyright message date updated to 2019
- README.md corrections
- Minor aesthetic corrections
  • Loading branch information...
faragon committed Jan 2, 2019
1 parent c4b8fdd commit b3daa7e683ec759e940fd5930487dd763ca77b27
@@ -1,4 +1,4 @@
Copyright (c) 2015-2018, F. Aragon
Copyright (c) 2015-2019, F. Aragon
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -5,7 +5,7 @@
#
# Platforms: POSIX systems (Linux, BSDs/Unix/Unix-like, etc.)
#
# Copyright (c) 2015-2018 F. Aragon. All rights reserved.
# Copyright (c) 2015-2019 F. Aragon. All rights reserved.
# Released under the BSD 3-Clause License (see the doc/LICENSE)
#

@@ -13,12 +13,12 @@ libsrt is a C library that provides string, vector, bit set, set, map, hash set,

Key points:

* Easy: write high-level-like C code. Write code faster and safer.
* Safe: write high-level-like C code. Write code faster and safer.
* Fast: using O(n)/O(log n)/O(1) state of the art algorithms.
* Useful: strings supporting raw data handling (per-byte), vector, set, map, hash set, and hash map data structures.
* Rich: strings supporting raw data handling (per-byte), vector, bit set, set, map, hash set, and hash map data structures.
* Efficient: space optimized, minimum allocation calls (heap and stack support for ALL data structures).
* Compatible: OS-independent (e.g. built-in space-optimized UTF-8 support).
* Predictable: suitable for microcontrollers and hard real-time compliant code.
* Predictable: intended for both general purpose and for hard real-time applications.
* Unicode: although string internal representation is raw data (bytes), functions for handling Unicode interpretation/generation/transformation are provided, so when Unicode-specific functions are used, the result of these functions is stored internally as UTF-8 (also, caching some operations, like Unicode string length -e.g. ss\_len()/ss\_size() give length in bytes, and ss\_len\_u() the length in Unicode characters-).

How to build
@@ -130,7 +130,6 @@ Generic disadvantages/limitations
===

* Double pointer usage: because of using just one allocation, write operations require to address a double pointer, so in the case of reallocation the source pointer could be changed.

* Concurrent read-only operations are safe, but concurrent read/write must be protected by the user (e.g. using mutexes or spinlocks). That can be seen as a disadvantage or as a "feature" (it is faster).

String-specific advantages (srt\_string)
@@ -226,8 +225,8 @@ Set and map advantages (srt\_set and srt\_map)
Set and map disadvantages/limitations (srt\_set and srt\_map)
===
* Because of being implemented as a tree, it can slower than a hash-map on average, specially on integer data. However, total execution time is not that bad, as because of allocation heuristics a lot of calls to the allocator are avoided.
* There is room for node deletion speed up (currently deletion is a bit slower than insertion, because of an additional tree search used for avoiding having memory fragmentation, as implementation guarantees linear/compacted memory usage, it could be optimized with a small LRU for cases of multiple delete/insert operation mix).
* Because of being implemented as a tree, it can be slower than a hash-map on average, specially on integer data. However, total execution time is not that bad, as because of allocation heuristics a lot of calls to the allocator are avoided.
* There is room for node deletion speed-up (currently deletion is a bit slower than insertion, because of an additional tree search used for avoiding having memory fragmentation, as implementation guarantees linear/compacted memory usage, it could be optimized with a small LRU for cases of multiple delete/insert operation mix).
Hash set and hash map advantages (srt\_hset and srt\_hmap)
===
@@ -273,7 +272,7 @@ Test-covered platforms
License
===
Copyright (c) 2015-2018, F. Aragon. All rights reserved.
Copyright (c) 2015-2019, F. Aragon. All rights reserved.
Released under the BSD 3-Clause License (see the LICENSE file included).
Contact
@@ -293,4 +292,3 @@ Acknowledgements and references
---
Check [doc/references.md](https://github.com/faragon/libsrt/blob/master/doc/references.md)
@@ -3,7 +3,7 @@
*
* Benchmarks of libsrt vs C++ STL
*
* Copyright (c) 2015-2018, F. Aragon. All rights reserved. Released under
* Copyright (c) 2015-2019 F. Aragon. All rights reserved. Released under
* the BSD 3-Clause License (see the doc/LICENSE file included).
*/

@@ -767,7 +767,7 @@ bool libsrt_vector_i(enum eSV_Type t, size_t count, int tid)
for (size_t i = 0; i < count; i++)
(void)sv_pop_i(v);
if (TIdTest(tid, TId_Sort10Times) || TIdTest(tid, TId_Sort10000Times)) {
const size_t cnt = TIdTest(tid, TId_Sort10Times) ? 10 : 10000;
size_t cnt = TIdTest(tid, TId_Sort10Times) ? 10 : 10000;
for (size_t i = 0; i < cnt; i++)
sv_sort(v);
}
@@ -837,7 +837,7 @@ bool cxx_vector(size_t count, int tid)
for (size_t i = 0; i < count; i++)
(void)v.pop_back();
if (TIdTest(tid, TId_Sort10Times) || TIdTest(tid, TId_Sort10000Times)) {
const size_t cnt = TIdTest(tid, TId_Sort10Times) ? 10 : 10000;
size_t cnt = TIdTest(tid, TId_Sort10Times) ? 10 : 10000;
for (size_t i = 0; i < cnt; i++)
std::sort(v.begin(), v.end());
}
@@ -922,7 +922,7 @@ bool libsrt_vector_gen(size_t count, int tid)
for (size_t i = 0; i < count; i++)
(void)sv_pop(v);
if (TIdTest(tid, TId_Sort10Times) || TIdTest(tid, TId_Sort10000Times)) {
const size_t cnt = TIdTest(tid, TId_Sort10Times) ? 10 : 10000;
size_t cnt = TIdTest(tid, TId_Sort10Times) ? 10 : 10000;
for (size_t i = 0; i < cnt; i++)
sv_sort(v);
}
@@ -949,7 +949,7 @@ bool cxx_vector_gen(size_t count, int tid)
for (size_t i = 0; i < count; i++)
(void)v.pop_back();
if (TIdTest(tid, TId_Sort10Times) || TIdTest(tid, TId_Sort10000Times)) {
const size_t cnt = TIdTest(tid, TId_Sort10Times) ? 10 : 10000;
size_t cnt = TIdTest(tid, TId_Sort10Times) ? 10 : 10000;
for (size_t i = 0; i < cnt; i++)
std::sort(v.begin(), v.end());
}
@@ -3,13 +3,13 @@
*
* Code counting example using libsrt
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*/

#include "../src/libsrt.h"

static int syntax_error(const char **argv, const int exit_code)
static int syntax_error(const char **argv, int exit_code)
{
const char *v0 = argv[0];
fprintf(stderr,
@@ -3,7 +3,7 @@
*
* Buffer encoding/decoding example using libsrt
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*/

@@ -3,13 +3,13 @@
*
* Histogram example using libsrt
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*/

#include "../src/libsrt.h"

static int syntax_error(const char **argv, const int exit_code)
static int syntax_error(const char **argv, int exit_code)
{
const char *v0 = argv[0];
fprintf(stderr,
@@ -3,7 +3,7 @@
*
* Image processing example using libsrt
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*/

@@ -3,7 +3,7 @@
*
* Image processing example using libsrt
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*
* Observations:
@@ -12,8 +12,7 @@

#include "imgtools.h"

static int exit_with_error(const char **argv, const char *msg,
const int exit_code);
static int exit_with_error(const char **argv, const char *msg, int exit_code);

int main(int argc, const char **argv)
{
@@ -92,8 +91,7 @@ int main(int argc, const char **argv)
return exit_code ? exit_with_error(argv, exit_msg, exit_code) : 0;
}

static int exit_with_error(const char **argv, const char *msg,
const int exit_code)
static int exit_with_error(const char **argv, const char *msg, int exit_code)
{
const char *v0 = argv[0];
fprintf(stderr,
@@ -3,7 +3,7 @@
*
* Image comparison/diff example using libsrt
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*
* Observations:
@@ -12,8 +12,7 @@

#include "imgtools.h"

static int exit_with_error(const char **argv, const char *msg,
const int exit_code);
static int exit_with_error(const char **argv, const char *msg, int exit_code);

int main(int argc, const char **argv)
{
@@ -107,8 +106,7 @@ int main(int argc, const char **argv)
return exit_code > 1 ? exit_with_error(argv, exit_msg, exit_code) : 0;
}

static int exit_with_error(const char **argv, const char *msg,
const int exit_code)
static int exit_with_error(const char **argv, const char *msg, int exit_code)
{
const char *v0 = argv[0];
fprintf(stderr,
@@ -3,7 +3,7 @@
*
* Image processing example using libsrt
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*
* Observations:
@@ -56,8 +56,8 @@ static srt_bool valid_tga(const char *h)
&& (h[TGA_TYPE] == TGA_RAW_RGB || h[TGA_TYPE] == TGA_RAW_GRAY);
}

static srt_bool tga_rgb_swap(const size_t bpp, const size_t buf_size,
const char *s, char *t)
static srt_bool tga_rgb_swap(size_t bpp, size_t buf_size, const char *s,
char *t)
{
size_t i;
RETURN_IF(!s || !t, S_FALSE);
@@ -86,8 +86,7 @@ static size_t tga2rgb(srt_string **rgb, struct RGB_Info *ri,
const srt_string *tga)
{
const char *t = ss_get_buffer_r(tga);
const size_t ts = ss_size(tga);
size_t rgb_bytes;
size_t ts = ss_size(tga), rgb_bytes;
ssize_t i;
RETURN_IF(ts < TGA_RGBHDR || !valid_tga(t), 0);
rgbi_set(ri, S_LD_LE_U16(t + TGA_W), S_LD_LE_U16(t + TGA_H),
@@ -628,7 +627,7 @@ static size_t rgb_info(const srt_string *rgb, const struct RGB_Info *ri)
size_t off2;
unsigned pixels, l, r, c;
if (rgb && ri) {
const size_t ss = ss_size(rgb);
size_t ss = ss_size(rgb);
size_t cmax = ri->bpp == 32 ? 0xffffffff
: 0xffffffff & ((1 << ri->bpp) - 1);
size_t i, uqp = 0;
@@ -701,7 +700,7 @@ size_t any2rgb(srt_string **rgb, struct RGB_Info *ri, const srt_string *in,

/* clang-format off */
size_t rgb2type(srt_string **out, enum ImgTypes ot, const srt_string *rgb0,
const struct RGB_Info *ri, const int f)
const struct RGB_Info *ri, int f)
{
size_t r;
srt_string *rgb_aux = NULL;
@@ -3,7 +3,7 @@
*
* Image processing example using libsrt
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*
* Observations:
@@ -80,7 +80,7 @@ enum Filters {
size_t any2rgb(srt_string **rgb, struct RGB_Info *ri, const srt_string *in,
enum ImgTypes in_type);
size_t rgb2type(srt_string **out, enum ImgTypes out_type, const srt_string *rgb,
const struct RGB_Info *ri, const int filter);
const struct RGB_Info *ri, int filter);
enum ImgTypes file_type(const char *file_name);
int rgbdiff(srt_string **out, const srt_string *rgb0,
const struct RGB_Info *ri0, const srt_string *rgb1,
@@ -3,7 +3,7 @@
*
* RGB bitmap description. Image processing example for libsrt.
*
* Copyright (c) 2015-2018 F. Aragon. All rights reserved.
* Copyright (c) 2015-2019 F. Aragon. All rights reserved.
* Released under the BSD 3-Clause License (see the doc/LICENSE)
*/

0 comments on commit b3daa7e

Please sign in to comment.
You can’t perform that action at this time.