Skip to content

Commit 5393d53

Browse files
committed
refactor: update API signatures and docs for clarity
- Make constructors explicit in several classes for safer conversions. - Add default initialization for sRect in cKDNode. - Mark destructors as override where appropriate. - Change cFile::write to take const void* for correctness. - Update stb README: fix typos, clarify authorship, and reflect latest versions and file names.
1 parent d6dbe3c commit 5393d53

9 files changed

Lines changed: 20 additions & 18 deletions

File tree

src/Atlas/AtlasPacker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ bool AtlasPacker::generateResFile(cFile& file, const std::string& atlasName)
245245
hotspot.x, hotspot.y);
246246
}
247247

248-
file.write((void*)out.c_str(), out.length());
248+
file.write(out.c_str(), out.length());
249249

250250
return true;
251251
}

src/Atlas/AtlasSize.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct sConfig;
1515
class cAtlasSize final
1616
{
1717
public:
18-
cAtlasSize(const sConfig& config);
18+
explicit cAtlasSize(const sConfig& config);
1919

2020
void addRect(const sSize& size);
2121
uint32_t getArea() const;

src/Atlas/KDNode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ class cKDNode final
3838
cKDNode* m_childA = nullptr; // left or top
3939
cKDNode* m_childB = nullptr; // right or bottom
4040

41-
sRect m_rect;
41+
sRect m_rect{ 0u, 0u, 0u, 0u };
4242
};

src/Atlas/KDTreePacker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class cKDNode;
1717
class KDTreePacker final : public AtlasPacker
1818
{
1919
public:
20-
KDTreePacker(const sConfig& config);
21-
~KDTreePacker();
20+
explicit KDTreePacker(const sConfig& config);
21+
~KDTreePacker() override;
2222

2323
static bool Compare(const cImage* a, const cImage* b);
2424

src/Atlas/SimplePacker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SimplePacker final : public AtlasPacker
1717
{
1818
public:
1919
SimplePacker(uint32_t count, const sConfig& config);
20-
~SimplePacker();
20+
~SimplePacker() override;
2121

2222
static bool Compare(const cImage* a, const cImage* b);
2323

src/File.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ uint32_t cFile::read(void* ptr, uint32_t size) const
5959
return 0u;
6060
}
6161

62-
uint32_t cFile::write(void* ptr, uint32_t size) const
62+
uint32_t cFile::write(const void* ptr, uint32_t size) const
6363
{
6464
if (m_file != nullptr)
6565
{

src/File.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class cFile final
2424

2525
uint32_t seek(uint32_t offset, int whence) const;
2626
uint32_t read(void* ptr, uint32_t size) const;
27-
uint32_t write(void* ptr, uint32_t size) const;
27+
uint32_t write(const void* ptr, uint32_t size) const;
2828

2929
long getSize() const
3030
{

src/Trim.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class cTrim
4444
class cTrimRigthBottom final : public cTrim
4545
{
4646
public:
47-
cTrimRigthBottom(const sConfig& config);
47+
explicit cTrimRigthBottom(const sConfig& config);
4848

4949
virtual bool trim(const char* path, const cBitmap& input) override;
5050

src/stb/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,29 @@ stb
55

66
single-file public domain (or MIT licensed) libraries for C/C++
77

8+
# This project discusses security-relevant bugs in public in Github Issues and Pull Requests, and it may take significant time for security fixes to be implemented or merged. If this poses an unreasonable risk to your project, do not use stb libraries.
9+
810
Noteworthy:
911

1012
* image loader: [stb_image.h](stb_image.h)
1113
* image writer: [stb_image_write.h](stb_image_write.h)
12-
* image resizer: [stb_image_resize.h](stb_image_resize.h)
14+
* image resizer: [stb_image_resize2.h](stb_image_resize2.h)
1315
* font text rasterizer: [stb_truetype.h](stb_truetype.h)
1416
* typesafe containers: [stb_ds.h](stb_ds.h)
1517

16-
Most libraries by stb, except: stb_dxt by Fabian "ryg" Giesen, stb_image_resize
17-
by Jorge L. "VinoBS" Rodriguez, and stb_sprintf by Jeff Roberts.
18+
Most libraries by stb, except: stb_dxt by Fabian "ryg" Giesen, original stb_image_resize
19+
by Jorge L. "VinoBS" Rodriguez, and stb_image_resize2 and stb_sprintf by Jeff Roberts.
1820

1921
<a name="stb_libs"></a>
2022

21-
library | lastest version | category | LoC | description
23+
library | latest version | category | LoC | description
2224
--------------------- | ---- | -------- | --- | --------------------------------
2325
**[stb_vorbis.c](stb_vorbis.c)** | 1.22 | audio | 5584 | decode ogg vorbis files from file/memory to float/16-bit signed output
2426
**[stb_hexwave.h](stb_hexwave.h)** | 0.5 | audio | 680 | audio waveform synthesizer
25-
**[stb_image.h](stb_image.h)** | 2.28 | graphics | 7987 | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
26-
**[stb_truetype.h](stb_truetype.h)** | 1.26 | graphics | 5077 | parse, decode, and rasterize characters from truetype fonts
27+
**[stb_image.h](stb_image.h)** | 2.30 | graphics | 7988 | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
28+
**[stb_truetype.h](stb_truetype.h)** | 1.26 | graphics | 5079 | parse, decode, and rasterize characters from truetype fonts
2729
**[stb_image_write.h](stb_image_write.h)** | 1.16 | graphics | 1724 | image writing to disk: PNG, TGA, BMP
28-
**[stb_image_resize.h](stb_image_resize.h)** | 0.97 | graphics | 2634 | resize images larger/smaller with good quality
30+
**[stb_image_resize2.h](stb_image_resize2.h)** | 2.16 | graphics | 10650 | resize images larger/smaller with good quality
2931
**[stb_rect_pack.h](stb_rect_pack.h)** | 1.01 | graphics | 623 | simple 2D rectangle packer with decent quality
3032
**[stb_perlin.h](stb_perlin.h)** | 0.5 | graphics | 428 | perlin's revised simplex noise w/ different seeds
3133
**[stb_ds.h](stb_ds.h)** | 0.67 | utility | 1895 | typesafe dynamic array and hash tables for C, will compile in C++
@@ -36,14 +38,14 @@ library | lastest version | category | LoC | description
3638
**[stb_easy_font.h](stb_easy_font.h)** | 1.1 | 3D&nbsp;graphics | 305 | quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc
3739
**[stb_tilemap_editor.h](stb_tilemap_editor.h)** | 0.42 | game&nbsp;dev | 4187 | embeddable tilemap editor
3840
**[stb_herringbone_wa...](stb_herringbone_wang_tile.h)** | 0.7 | game&nbsp;dev | 1221 | herringbone Wang tile map generator
39-
**[stb_c_lexer.h](stb_c_lexer.h)** | 0.12 | parsing | 940 | simplify writing parsers for C-like languages
41+
**[stb_c_lexer.h](stb_c_lexer.h)** | 0.12 | parsing | 941 | simplify writing parsers for C-like languages
4042
**[stb_divide.h](stb_divide.h)** | 0.94 | math | 433 | more useful 32-bit modulus e.g. "euclidean divide"
4143
**[stb_connected_comp...](stb_connected_components.h)** | 0.96 | misc | 1049 | incrementally compute reachability on grids
4244
**[stb_leakcheck.h](stb_leakcheck.h)** | 0.6 | misc | 194 | quick-and-dirty malloc/free leak-checking
4345
**[stb_include.h](stb_include.h)** | 0.02 | misc | 295 | implement recursive #include support, particularly for GLSL
4446

4547
Total libraries: 21
46-
Total lines of C code: 43117
48+
Total lines of C code: 51137
4749

4850

4951
FAQ

0 commit comments

Comments
 (0)