Skip to content

Commit

Permalink
fix: apply modernize-use-nullptr (rdkit#8134)
Browse files Browse the repository at this point in the history
Co-authored-by: Eisuke Kawashima <[email protected]>
  • Loading branch information
e-kwsm and e-kwsm authored Jan 9, 2025
1 parent b17b81d commit 41a2a79
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions Code/GraphMol/FilterCatalog/Filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ const FilterData_t *GetFilterData(FilterCatalogParams::FilterCatalogs catalog) {
case FilterCatalogParams::CHEMBL_LINT:
return CHEMBL_LINT;
default:
return 0;
return nullptr;
}
}

Expand Down Expand Up @@ -599,7 +599,7 @@ const FilterProperty_t *GetFilterProperties(
case FilterCatalogParams::CHEMBL_LINT:
return CHEMBL_LINT_PROPS;
default:
return 0;
return nullptr;
}
}
} // namespace RDKit
2 changes: 1 addition & 1 deletion Code/GraphMol/NontetrahedralStereo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ Bond *getTrigonalBipyramidalAxialBond(const Atom *cen, int axial) {

unsigned int perm = 0;
cen->getPropIfPresent(RDKit::common_properties::_chiralPermutation, perm);
if (perm == 0 || perm > 20) return 0;
if (perm == 0 || perm > 20) return nullptr;

unsigned int idx = (axial != -1) ? trigonalbipyramidal_axial[perm][0]
: trigonalbipyramidal_axial[perm][1];
Expand Down
40 changes: 20 additions & 20 deletions Code/GraphMol/SmilesParse/lex.yysmarts.cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
}
else
/* Can't grow it, we don't own it. */
b->yy_ch_buf = NULL;
b->yy_ch_buf = nullptr;

if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
Expand Down Expand Up @@ -2497,7 +2497,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner)
return;

if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) nullptr;

if ( b->yy_is_our_buffer )
yyfree( (void *) b->yy_ch_buf , yyscanner );
Expand Down Expand Up @@ -2571,7 +2571,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner)
void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
if (new_buffer == nullptr)
return;

yyensure_buffer_stack(yyscanner);
Expand Down Expand Up @@ -2606,7 +2606,7 @@ void yypop_buffer_state (yyscan_t yyscanner)
return;

yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
YY_CURRENT_BUFFER_LVALUE = nullptr;
if (yyg->yy_buffer_stack_top > 0)
--yyg->yy_buffer_stack_top;

Expand Down Expand Up @@ -2677,7 +2677,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscann
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return NULL;
return nullptr;

b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
Expand All @@ -2686,7 +2686,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscann
b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
b->yy_input_file = nullptr;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
Expand Down Expand Up @@ -2985,14 +2985,14 @@ void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
*/
int yylex_init(yyscan_t* ptr_yy_globals)
{
if (ptr_yy_globals == NULL){
if (ptr_yy_globals == nullptr){
errno = EINVAL;
return 1;
}

*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), nullptr );

if (*ptr_yy_globals == NULL){
if (*ptr_yy_globals == nullptr){
errno = ENOMEM;
return 1;
}
Expand All @@ -3016,14 +3016,14 @@ int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )

yyset_extra (yy_user_defined, &dummy_yyguts);

if (ptr_yy_globals == NULL){
if (ptr_yy_globals == nullptr){
errno = EINVAL;
return 1;
}

*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );

if (*ptr_yy_globals == NULL){
if (*ptr_yy_globals == nullptr){
errno = ENOMEM;
return 1;
}
Expand All @@ -3044,24 +3044,24 @@ static int yy_init_globals (yyscan_t yyscanner)
* This function is called from yylex_destroy(), so don't allocate here.
*/

yyg->yy_buffer_stack = NULL;
yyg->yy_buffer_stack = nullptr;
yyg->yy_buffer_stack_top = 0;
yyg->yy_buffer_stack_max = 0;
yyg->yy_c_buf_p = NULL;
yyg->yy_c_buf_p = nullptr;
yyg->yy_init = 0;
yyg->yy_start = 0;

yyg->yy_start_stack_ptr = 0;
yyg->yy_start_stack_depth = 0;
yyg->yy_start_stack = NULL;
yyg->yy_start_stack = nullptr;

/* Defined in main.c */
#ifdef YY_STDINIT
yyin = stdin;
yyout = stdout;
#else
yyin = NULL;
yyout = NULL;
yyin = nullptr;
yyout = nullptr;
#endif

/* For future reference: Set errno on error, since we are called by
Expand All @@ -3078,25 +3078,25 @@ int yylex_destroy (yyscan_t yyscanner)
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
YY_CURRENT_BUFFER_LVALUE = nullptr;
yypop_buffer_state(yyscanner);
}

/* Destroy the stack itself. */
yyfree(yyg->yy_buffer_stack , yyscanner);
yyg->yy_buffer_stack = NULL;
yyg->yy_buffer_stack = nullptr;

/* Destroy the start condition stack. */
yyfree( yyg->yy_start_stack , yyscanner );
yyg->yy_start_stack = NULL;
yyg->yy_start_stack = nullptr;

/* Reset the globals. This is important in a non-reentrant scanner so the next time
* yylex() is called, initialization will occur. */
yy_init_globals( yyscanner);

/* Destroy the main struct (reentrant only). */
yyfree ( yyscanner , yyscanner );
yyscanner = NULL;
yyscanner = nullptr;
return 0;
}

Expand Down
40 changes: 20 additions & 20 deletions Code/GraphMol/SmilesParse/lex.yysmiles.cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
}
else
/* Can't grow it, we don't own it. */
b->yy_ch_buf = NULL;
b->yy_ch_buf = nullptr;

if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
Expand Down Expand Up @@ -2560,7 +2560,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner)
return;

if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) nullptr;

if ( b->yy_is_our_buffer )
yyfree( (void *) b->yy_ch_buf , yyscanner );
Expand Down Expand Up @@ -2634,7 +2634,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner)
void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
if (new_buffer == nullptr)
return;

yyensure_buffer_stack(yyscanner);
Expand Down Expand Up @@ -2669,7 +2669,7 @@ void yypop_buffer_state (yyscan_t yyscanner)
return;

yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
YY_CURRENT_BUFFER_LVALUE = nullptr;
if (yyg->yy_buffer_stack_top > 0)
--yyg->yy_buffer_stack_top;

Expand Down Expand Up @@ -2740,7 +2740,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscann
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return NULL;
return nullptr;

b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
Expand All @@ -2749,7 +2749,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscann
b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
b->yy_input_file = nullptr;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
Expand Down Expand Up @@ -3007,14 +3007,14 @@ void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
*/
int yylex_init(yyscan_t* ptr_yy_globals)
{
if (ptr_yy_globals == NULL){
if (ptr_yy_globals == nullptr){
errno = EINVAL;
return 1;
}

*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), nullptr );

if (*ptr_yy_globals == NULL){
if (*ptr_yy_globals == nullptr){
errno = ENOMEM;
return 1;
}
Expand All @@ -3038,14 +3038,14 @@ int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )

yyset_extra (yy_user_defined, &dummy_yyguts);

if (ptr_yy_globals == NULL){
if (ptr_yy_globals == nullptr){
errno = EINVAL;
return 1;
}

*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );

if (*ptr_yy_globals == NULL){
if (*ptr_yy_globals == nullptr){
errno = ENOMEM;
return 1;
}
Expand All @@ -3066,24 +3066,24 @@ static int yy_init_globals (yyscan_t yyscanner)
* This function is called from yylex_destroy(), so don't allocate here.
*/

yyg->yy_buffer_stack = NULL;
yyg->yy_buffer_stack = nullptr;
yyg->yy_buffer_stack_top = 0;
yyg->yy_buffer_stack_max = 0;
yyg->yy_c_buf_p = NULL;
yyg->yy_c_buf_p = nullptr;
yyg->yy_init = 0;
yyg->yy_start = 0;

yyg->yy_start_stack_ptr = 0;
yyg->yy_start_stack_depth = 0;
yyg->yy_start_stack = NULL;
yyg->yy_start_stack = nullptr;

/* Defined in main.c */
#ifdef YY_STDINIT
yyin = stdin;
yyout = stdout;
#else
yyin = NULL;
yyout = NULL;
yyin = nullptr;
yyout = nullptr;
#endif

/* For future reference: Set errno on error, since we are called by
Expand All @@ -3100,25 +3100,25 @@ int yylex_destroy (yyscan_t yyscanner)
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
YY_CURRENT_BUFFER_LVALUE = nullptr;
yypop_buffer_state(yyscanner);
}

/* Destroy the stack itself. */
yyfree(yyg->yy_buffer_stack , yyscanner);
yyg->yy_buffer_stack = NULL;
yyg->yy_buffer_stack = nullptr;

/* Destroy the start condition stack. */
yyfree( yyg->yy_start_stack , yyscanner );
yyg->yy_start_stack = NULL;
yyg->yy_start_stack = nullptr;

/* Reset the globals. This is important in a non-reentrant scanner so the next time
* yylex() is called, initialization will occur. */
yy_init_globals( yyscanner);

/* Destroy the main struct (reentrant only). */
yyfree ( yyscanner , yyscanner );
yyscanner = NULL;
yyscanner = nullptr;
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions Code/JavaWrappers/MorganFingerprints.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ RDKit::SparseIntVect<std::uint32_t> *getFeatureFingerprint(
RDKit::MorganFingerprints::getFeatureInvariants(mol, *invars);
RDKit::SparseIntVect<std::uint32_t> *res =
RDKit::MorganFingerprints::getFingerprint(
mol, static_cast<unsigned int>(radius), invars, 0, useChirality,
useBondTypes, useCounts, false, 0);
mol, static_cast<unsigned int>(radius), invars, nullptr, useChirality,
useBondTypes, useCounts, false, nullptr);
delete invars;
return res;
}
2 changes: 1 addition & 1 deletion Code/RDGeneral/LocaleSwitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class LocaleSwitcherImpl {
// set locale for this thread

if (!recurseLocale(CurrentState)) {
auto loc = newlocale(LC_ALL_MASK, "C", (locale_t)0);
auto loc = newlocale(LC_ALL_MASK, "C", (locale_t) nullptr);
old_loc = uselocale(loc);
recurseLocale(SwitchLocale);
switched = true;
Expand Down
10 changes: 5 additions & 5 deletions Code/SimDivPickers/LeaderPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ struct LeaderPickerState {
// InitializeThreads
if (nt > 1) {
nthreads = nt;
pthread_barrier_init(&wait, NULL, nthreads + 1);
pthread_barrier_init(&done, NULL, nthreads + 1);
pthread_barrier_init(&wait, nullptr, nthreads + 1);
pthread_barrier_init(&done, nullptr, nthreads + 1);

threads.resize(nt);
for (unsigned int i = 0; i < nthreads; i++) {
threads[i].id = i;
threads[i].stat = this;
pthread_create(&threads[i].tid, NULL, LeaderPickerWork<T>,
pthread_create(&threads[i].tid, nullptr, LeaderPickerWork<T>,
(void *)&threads[i]);
}
} else {
Expand All @@ -236,7 +236,7 @@ struct LeaderPickerState {
thread_op = 1;
pthread_barrier_wait(&wait);
for (unsigned int i = 0; i < nthreads; i++) {
pthread_join(threads[i].tid, 0);
pthread_join(threads[i].tid, nullptr);
}
pthread_barrier_destroy(&wait);
pthread_barrier_destroy(&done);
Expand Down Expand Up @@ -339,7 +339,7 @@ void *LeaderPickerWork(void *arg) {
for (;;) {
pthread_barrier_wait(&stat->wait);
if (stat->thread_op) {
return (void *)0;
return (void *)nullptr;
}
stat->compact_job(thread->id);
pthread_barrier_wait(&stat->done);
Expand Down

0 comments on commit 41a2a79

Please sign in to comment.