Skip to content

Commit ed95382

Browse files
committed
Merge pull request matplotlib#3691 from mdboom/more-cpp-cleanup
Minor C++ improvements
2 parents 6091d11 + 001eb3d commit ed95382

12 files changed

+35
-61
lines changed

extern/ttconv/pprdrv_tt.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#include "pprdrv.h"
3232
#include "truetype.h"
3333
#include <sstream>
34+
#ifdef _POSIX_C_SOURCE
35+
# undef _POSIX_C_SOURCE
36+
#endif
37+
#ifdef _XOPEN_SOURCE
38+
# undef _XOPEN_SOURCE
39+
#endif
3440
#include <Python.h>
3541

3642
/*==========================================================================

src/_backend_agg_wrapper.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,7 @@ extern "C" {
670670

671671
struct module_state
672672
{
673-
/* The Sun compiler can't handle empty structs */
674-
#if defined(__SUNPRO_C) || defined(_MSC_VER)
675673
int _dummy;
676-
#endif
677674
};
678675

679676
#if PY3K

src/_gtkagg.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ extern "C" {
110110

111111
struct module_state
112112
{
113-
/* The Sun compiler can't handle empty structs */
114-
#if defined(__SUNPRO_C) || defined(_MSC_VER)
115113
int _dummy;
116-
#endif
117114
};
118115

119116
#if PY3K

src/_image_wrapper.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,7 @@ extern "C" {
722722

723723
struct module_state
724724
{
725-
/* The Sun compiler can't handle empty structs */
726-
#if defined(__SUNPRO_C) || defined(_MSC_VER)
727725
int _dummy;
728-
#endif
729726
};
730727

731728
#if PY3K

src/_path_wrapper.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,7 @@ extern "C" {
669669

670670
struct module_state
671671
{
672-
/* The Sun compiler can't handle empty structs */
673-
#if defined(__SUNPRO_C) || defined(_MSC_VER)
674672
int _dummy;
675-
#endif
676673
};
677674

678675
#if PY3K

src/_png.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,7 @@ extern "C" {
490490

491491
struct module_state
492492
{
493-
/* The Sun compiler can't handle empty structs */
494-
#if defined(__SUNPRO_C) || defined(_MSC_VER)
495493
int _dummy;
496-
#endif
497494
};
498495

499496
#if PY3K

src/cntr.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,9 @@ slit_cutter (Csite * site, int up, int pass2)
722722
* -- this never happens on the first pass */
723723
long p1 = site->edge;
724724
int z1;
725+
726+
assert(pass2);
727+
725728
for (;;)
726729
{
727730
z1 = data[p1] & Z_VALUE;
@@ -1406,7 +1409,11 @@ int reorder(double *xpp, double *ypp, short *kpp,
14061409

14071410
/* Find the subpaths as sets of connected segments. */
14081411

1409-
subp = (int *)malloc(nsegs * sizeof(int));
1412+
if (nsegs) {
1413+
subp = (int *)malloc(nsegs * sizeof(int));
1414+
} else {
1415+
subp = NULL;
1416+
}
14101417
for (i=0; i<nsegs; i++) subp[i] = -1;
14111418

14121419
nsp = 0;
@@ -2025,5 +2032,3 @@ init_cntr(void)
20252032
return m;
20262033
#endif
20272034
}
2028-
2029-

src/ft2font.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void FT2Image::resize(long width, long height)
7474
m_height = (unsigned long)height;
7575
}
7676

77-
if (numBytes) {
77+
if (numBytes && m_buffer) {
7878
memset(m_buffer, 0, numBytes);
7979
}
8080

src/ft2font_wrapper.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,10 +1618,7 @@ extern "C" {
16181618

16191619
struct module_state
16201620
{
1621-
/* The Sun compiler can't handle empty structs */
1622-
#if defined(__SUNPRO_C) || defined(_MSC_VER)
16231621
int _dummy;
1624-
#endif
16251622
};
16261623

16271624
#if PY3K

src/mplutils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ typedef unsigned __int8 uint8_t;
1111
#include <stdint.h>
1212
#endif
1313

14+
#ifdef _POSIX_C_SOURCE
15+
# undef _POSIX_C_SOURCE
16+
#endif
17+
#ifdef _XOPEN_SOURCE
18+
# undef _XOPEN_SOURCE
19+
#endif
20+
1421
#include <Python.h>
1522

1623
#if PY_MAJOR_VERSION >= 3

0 commit comments

Comments
 (0)