From bade6ae30109f88d4892624a01bb19e794c15c1b Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Tue, 19 Mar 2024 15:40:09 +0100 Subject: C++ migration: NULL → nullptr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cancel.cpp | 6 +++--- src/keeper.cpp | 36 +++++++++++++++---------------- src/lanes.cpp | 62 ++++++++++++++++++++++++++--------------------------- src/lanes_private.h | 6 +++--- src/linda.cpp | 46 +++++++++++++++++++-------------------- src/universe.cpp | 2 +- 6 files changed, 79 insertions(+), 79 deletions(-) (limited to 'src') diff --git a/src/cancel.cpp b/src/cancel.cpp index 0a5adb6..8558008 100644 --- a/src/cancel.cpp +++ b/src/cancel.cpp @@ -84,7 +84,7 @@ static void cancel_hook( lua_State* L, lua_Debug* ar) DEBUGSPEW_CODE( fprintf( stderr, "cancel_hook\n")); if( cancel_test( L) != CANCEL_NONE) { - lua_sethook( L, NULL, 0, 0); + lua_sethook( L, nullptr, 0, 0); cancel_error( L); } } @@ -119,7 +119,7 @@ static cancel_result thread_cancel_soft( Lane* s, double secs_, bool_t wake_lind if( wake_lindas_) // wake the thread so that execution returns from any pending linda operation if desired { SIGNAL_T *waiting_on = s->waiting_on; - if( s->status == WAITING && waiting_on != NULL) + if( s->status == WAITING && waiting_on != nullptr) { SIGNAL_ALL( waiting_on); } @@ -137,7 +137,7 @@ static cancel_result thread_cancel_hard( lua_State* L, Lane* s, double secs_, bo s->cancel_request = CANCEL_HARD; // it's now signaled to stop { SIGNAL_T *waiting_on = s->waiting_on; - if( s->status == WAITING && waiting_on != NULL) + if( s->status == WAITING && waiting_on != nullptr) { SIGNAL_ALL( waiting_on); } diff --git a/src/keeper.cpp b/src/keeper.cpp index 8aa734a..10fba2b 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp @@ -72,7 +72,7 @@ static int const CONTENTS_TABLE = 1; static keeper_fifo* prepare_fifo_access( lua_State* L, int idx_) { keeper_fifo* fifo = (keeper_fifo*) lua_touserdata( L, idx_); - if( fifo != NULL) + if( fifo != nullptr) { idx_ = lua_absindex( L, idx_); STACK_GROW( L, 1); @@ -192,8 +192,8 @@ static void push_table( lua_State* L, int idx_) int keeper_push_linda_storage( Universe* U, lua_State* L, void* ptr_, ptrdiff_t magic_) { Keeper* const K = which_keeper( U->keepers, magic_); - lua_State* const KL = K ? K->L : NULL; - if( KL == NULL) return 0; + lua_State* const KL = K ? K->L : nullptr; + if( KL == nullptr) return 0; STACK_GROW( KL, 4); STACK_CHECK( KL, 0); REGISTRY_GET( KL, FIFOS_KEY); // fifos @@ -303,7 +303,7 @@ int keepercall_receive( lua_State* L) lua_pushvalue( L, i); // fifos keys key[i] lua_rawget( L, 1); // fifos keys fifo fifo = prepare_fifo_access( L, -1); // fifos keys fifo - if( fifo != NULL && fifo->count > 0) + if( fifo != nullptr && fifo->count > 0) { fifo_pop( L, fifo, 1); // fifos keys val if( !lua_isnil( L, -1)) @@ -341,7 +341,7 @@ int keepercall_receive_batched( lua_State* L) lua_rawget( L, 2); // key fifos fifo lua_remove( L, 2); // key fifo fifo = prepare_fifo_access( L, 2); // key fifo - if( fifo != NULL && fifo->count >= min_count) + if( fifo != nullptr && fifo->count >= min_count) { fifo_pop( L, fifo, __min( max_count, fifo->count)); // key ... } @@ -369,7 +369,7 @@ int keepercall_limit( lua_State* L) lua_pushvalue( L, -1); // fifos key key lua_rawget( L, -3); // fifos key fifo|nil fifo = (keeper_fifo*) lua_touserdata( L, -1); - if( fifo == NULL) + if( fifo == nullptr) { // fifos key nil lua_pop( L, 1); // fifos key fifo_new( L); // fifos key fifo @@ -412,7 +412,7 @@ int keepercall_set( lua_State* L) lua_rawget( L, 1); // fifos key fifo|nil // empty the fifo for the specified key: replace uservalue with a virgin table, reset counters, but leave limit unchanged! fifo = (keeper_fifo*) lua_touserdata( L, -1); - if( fifo != NULL) // might be NULL if we set a nonexistent key to nil + if( fifo != nullptr) // might be NULL if we set a nonexistent key to nil { // fifos key fifo if( fifo->limit < 0) // fifo limit value is the default (unlimited): we can totally remove it { @@ -439,7 +439,7 @@ int keepercall_set( lua_State* L) lua_pushvalue( L, 2); // fifos key [val [, ...]] key lua_rawget( L, 1); // fifos key [val [, ...]] fifo|nil fifo = (keeper_fifo*) lua_touserdata( L, -1); - if( fifo == NULL) // can be NULL if we store a value at a new key + if( fifo == nullptr) // can be nullptr if we store a value at a new key { // fifos key [val [, ...]] nil // no need to wake writers in that case, because a writer can't wait on an inexistent key lua_pop( L, 1); // fifos key [val [, ...]] @@ -481,7 +481,7 @@ int keepercall_get( lua_State* L) lua_replace( L, 1); // fifos key lua_rawget( L, 1); // fifos fifo fifo = prepare_fifo_access( L, -1); // fifos fifo - if( fifo != NULL && fifo->count > 0) + if( fifo != nullptr && fifo->count > 0) { lua_remove( L, 1); // fifo count = __min( count, fifo->count); @@ -548,7 +548,7 @@ int keepercall_count( lua_State* L) lua_rawget( L, 2); // out fifos keys fifo|nil fifo = prepare_fifo_access( L, -1); // out fifos keys fifo|nil lua_pop( L, 1); // out fifos keys - if( fifo != NULL) // the key is known + if( fifo != nullptr) // the key is known { lua_pushinteger( L, fifo->count); // out fifos keys count lua_rawset( L, 1); // out fifos keys @@ -582,7 +582,7 @@ int keepercall_count( lua_State* L) // called as __gc for the keepers array userdata void close_keepers( Universe* U) { - if( U->keepers != NULL) + if( U->keepers != nullptr) { int i; int nbKeepers = U->keepers->nb_keepers; @@ -594,8 +594,8 @@ void close_keepers( Universe* U) for( i = 0; i < nbKeepers; ++ i) { lua_State* K = U->keepers->keeper_array[i].L; - U->keepers->keeper_array[i].L = NULL; - if( K != NULL) + U->keepers->keeper_array[i].L = nullptr; + if( K != nullptr) { lua_close( K); } @@ -613,7 +613,7 @@ void close_keepers( Universe* U) { AllocatorDefinition* const allocD = &U->internal_allocator; (void) allocD->allocF( allocD->allocUD, U->keepers, sizeof( Keepers) + (nbKeepers - 1) * sizeof( Keeper), 0); - U->keepers = NULL; + U->keepers = nullptr; } } } @@ -648,9 +648,9 @@ void init_keepers( Universe* U, lua_State* L) size_t const bytes = sizeof( Keepers) + (nb_keepers - 1) * sizeof( Keeper); { AllocatorDefinition* const allocD = &U->internal_allocator; - U->keepers = (Keepers*) allocD->allocF( allocD->allocUD, NULL, 0, bytes); + U->keepers = (Keepers*) allocD->allocF( allocD->allocUD, nullptr, 0, bytes); } - if( U->keepers == NULL) + if( U->keepers == nullptr) { (void) luaL_error( L, "init_keepers() failed while creating keeper array; out of memory"); return; @@ -662,7 +662,7 @@ void init_keepers( Universe* U, lua_State* L) { // note that we will leak K if we raise an error later lua_State* K = create_state( U, L); - if( K == NULL) + if( K == nullptr) { (void) luaL_error( L, "init_keepers() failed while creating keeper states; out of memory"); return; @@ -734,7 +734,7 @@ Keeper* keeper_acquire( Keepers* keepers_, ptrdiff_t magic_) // can be 0 if this happens during main state shutdown (lanes is being GC'ed -> no keepers) if( nbKeepers == 0) { - return NULL; + return nullptr; } else { diff --git a/src/lanes.cpp b/src/lanes.cpp index deee90c..d97a539 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -176,7 +176,7 @@ static bool_t push_registry_table( lua_State* L, UniqueKey key, bool_t create) #if HAVE_LANE_TRACKING() -// The chain is ended by '(Lane*)(-1)', not NULL: +// The chain is ended by '(Lane*)(-1)', not nullptr: // 'tracking_first -> ... -> ... -> (-1)' #define TRACKING_END ((Lane *)(-1)) @@ -189,7 +189,7 @@ static void tracking_add( Lane* s) MUTEX_LOCK( &s->U->tracking_cs); { - assert( s->tracking_next == NULL); + assert( s->tracking_next == nullptr); s->tracking_next = s->U->tracking_first; s->U->tracking_first = s; @@ -209,7 +209,7 @@ static bool_t tracking_remove( Lane* s) // still (at process exit they will remove us from chain and then // cancel/kill). // - if( s->tracking_next != NULL) + if( s->tracking_next != nullptr) { Lane** ref = (Lane**) &s->U->tracking_first; @@ -218,7 +218,7 @@ static bool_t tracking_remove( Lane* s) if( *ref == s) { *ref = s->tracking_next; - s->tracking_next = NULL; + s->tracking_next = nullptr; found = TRUE; break; } @@ -246,7 +246,7 @@ static void lane_cleanup( Lane* s) #endif // THREADWAIT_METHOD == THREADWAIT_CONDVAR #if HAVE_LANE_TRACKING() - if( s->U->tracking_first != NULL) + if( s->U->tracking_first != nullptr) { // Lane was cleaned up, no need to handle at process termination tracking_remove( s); @@ -386,7 +386,7 @@ static int run_finalizers( lua_State* L, int lua_rc) #define SELFDESTRUCT_END ((Lane*)(-1)) // -// The chain is ended by '(Lane*)(-1)', not NULL: +// The chain is ended by '(Lane*)(-1)', not nullptr: // 'selfdestruct_first -> ... -> ... -> (-1)' /* @@ -396,7 +396,7 @@ static int run_finalizers( lua_State* L, int lua_rc) static void selfdestruct_add( Lane* s) { MUTEX_LOCK( &s->U->selfdestruct_cs); - assert( s->selfdestruct_next == NULL); + assert( s->selfdestruct_next == nullptr); s->selfdestruct_next = s->U->selfdestruct_first; s->U->selfdestruct_first= s; @@ -415,7 +415,7 @@ static bool_t selfdestruct_remove( Lane* s) // still (at process exit they will remove us from chain and then // cancel/kill). // - if( s->selfdestruct_next != NULL) + if( s->selfdestruct_next != nullptr) { Lane** ref = (Lane**) &s->U->selfdestruct_first; @@ -424,7 +424,7 @@ static bool_t selfdestruct_remove( Lane* s) if( *ref == s) { *ref = s->selfdestruct_next; - s->selfdestruct_next = NULL; + s->selfdestruct_next = nullptr; // the terminal shutdown should wait until the lane is done with its lua_close() ++ s->U->selfdestructing_count; found = TRUE; @@ -458,12 +458,12 @@ static int selfdestruct_gc( lua_State* L) // attempt a regular unforced hard cancel with a small timeout bool_t cancelled = THREAD_ISNULL( s->thread) || thread_cancel( L, s, CO_Hard, 0.0001, FALSE, 0.0); // if we failed, and we know the thread is waiting on a linda - if( cancelled == FALSE && s->status == WAITING && s->waiting_on != NULL) + if( cancelled == FALSE && s->status == WAITING && s->waiting_on != nullptr) { // signal the linda to wake up the thread so that it can react to the cancel query // let us hope we never land here with a pointer on a linda that has been destroyed... SIGNAL_T* waiting_on = s->waiting_on; - //s->waiting_on = NULL; // useful, or not? + //s->waiting_on = nullptr; // useful, or not? SIGNAL_ALL( waiting_on); } s = s->selfdestruct_next; @@ -540,8 +540,8 @@ static int selfdestruct_gc( lua_State* L) while( s != SELFDESTRUCT_END) { Lane* next_s = s->selfdestruct_next; - s->selfdestruct_next = NULL; // detach from selfdestruct chain - if( !THREAD_ISNULL( s->thread)) // can be NULL if previous 'soft' termination succeeded + s->selfdestruct_next = nullptr; // detach from selfdestruct chain + if( !THREAD_ISNULL( s->thread)) // can be nullptr if previous 'soft' termination succeeded { THREAD_KILL( &s->thread); #if THREADAPI == THREADAPI_PTHREAD @@ -572,11 +572,11 @@ static int selfdestruct_gc( lua_State* L) // necessary so that calling free_deep_prelude doesn't crash because linda_id expects a linda lightuserdata at absolute slot 1 lua_settop( L, 0); // no need to mutex-protect this as all threads in the universe are gone at that point - if( U->timer_deep != NULL) // test ins case some early internal error prevented Lanes from creating the deep timer + if( U->timer_deep != nullptr) // test ins case some early internal error prevented Lanes from creating the deep timer { -- U->timer_deep->refcount; // should be 0 now free_deep_prelude( L, (DeepPrelude*) U->timer_deep); - U->timer_deep = NULL; + U->timer_deep = nullptr; } close_keepers( U); @@ -596,7 +596,7 @@ static int selfdestruct_gc( lua_State* L) // universe is no longer available (nor necessary) // we need to do this in case some deep userdata objects were created before Lanes was initialized, // as potentially they will be garbage collected after Lanes at application shutdown - universe_store( L, NULL); + universe_store( L, nullptr); return 0; } @@ -868,7 +868,7 @@ static char const* get_errcode_name( int _code) return s_errcodes[i].name; } } - return ""; + return ""; } #endif // USE_DEBUG_SPEW() @@ -943,7 +943,7 @@ static THREAD_RETURN_T THREAD_CALLCONV lane_main( void* vs) // the finalizer generated an error, and left its own error message [and stack trace] on the stack rc = rc2; // we're overruling the earlier script error or normal return } - s->waiting_on = NULL; // just in case + s->waiting_on = nullptr; // just in case if( selfdestruct_remove( s)) // check and remove (under lock!) { // We're a free-running thread and no-one's there to clean us up. @@ -1228,9 +1228,9 @@ LUAG_FUNC( lane_new) ud = (Lane**) lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane { AllocatorDefinition* const allocD = &U->internal_allocator; - s = *ud = (Lane*) allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane)); + s = *ud = (Lane*) allocD->allocF(allocD->allocUD, nullptr, 0, sizeof(Lane)); } - if( s == NULL) + if( s == nullptr) { return luaL_error( L, "could not create lane: out of memory"); } @@ -1238,7 +1238,7 @@ LUAG_FUNC( lane_new) s->L = L2; s->U = U; s->status = PENDING; - s->waiting_on = NULL; + s->waiting_on = nullptr; s->debug_name = ""; s->cancel_request = CANCEL_NONE; @@ -1247,9 +1247,9 @@ LUAG_FUNC( lane_new) SIGNAL_INIT( &s->done_signal); #endif // THREADWAIT_METHOD == THREADWAIT_CONDVAR s->mstatus = NORMAL; - s->selfdestruct_next = NULL; + s->selfdestruct_next = nullptr; #if HAVE_LANE_TRACKING() - s->tracking_next = NULL; + s->tracking_next = nullptr; if( s->U->tracking_first) { tracking_add( s); @@ -1399,7 +1399,7 @@ static char const * thread_status_string( Lane* s) (st == WAITING) ? "waiting" : (st == DONE) ? "done" : (st == ERROR_ST) ? "error" : - (st == CANCELLED) ? "cancelled" : NULL; + (st == CANCELLED) ? "cancelled" : nullptr; return str; } @@ -1767,7 +1767,7 @@ static const struct luaL_Reg lanes_functions [] = { {"nameof", luaG_nameof}, {"register", LG_register}, {"set_singlethreaded", LG_set_singlethreaded}, - {NULL, NULL} + {nullptr, nullptr} }; /* @@ -1820,7 +1820,7 @@ static volatile long s_initCount = 0; LUAG_FUNC( configure) { Universe* U = universe_get( L); - bool_t const from_master_state = (U == NULL); + bool_t const from_master_state = (U == nullptr); char const* name = luaL_checkstring( L, lua_upvalueindex( 1)); _ASSERT_L( L, lua_type( L, 1) == LUA_TTABLE); @@ -1868,7 +1868,7 @@ LUAG_FUNC( configure) DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "%p: lanes.configure() BEGIN\n" INDENT_END, L)); DEBUGSPEW_CODE( if( U) ++ U->debugspew_indent_depth); - if( U == NULL) + if( U == nullptr) { U = universe_create( L); // settings universe DEBUGSPEW_CODE( ++ U->debugspew_indent_depth); @@ -1887,7 +1887,7 @@ LUAG_FUNC( configure) #if HAVE_LANE_TRACKING() MUTEX_INIT( &U->tracking_cs); lua_getfield( L, 1, "track_lanes"); // settings track_lanes - U->tracking_first = lua_toboolean( L, -1) ? TRACKING_END : NULL; + U->tracking_first = lua_toboolean( L, -1) ? TRACKING_END : nullptr; lua_pop( L, 1); // settings #endif // HAVE_LANE_TRACKING() // Linked chains handling @@ -1928,7 +1928,7 @@ LUAG_FUNC( configure) luaG_registerlibfuncs( L, lanes_functions); #if HAVE_LANE_TRACKING() // register core.threads() only if settings say it should be available - if( U->tracking_first != NULL) + if( U->tracking_first != nullptr) { lua_pushcfunction( L, LG_threads); // settings M LG_threads() lua_setfield( L, -2, "threads"); // settings M @@ -1939,7 +1939,7 @@ LUAG_FUNC( configure) { char const* errmsg; errmsg = push_deep_proxy( U, L, (DeepPrelude*) U->timer_deep, 0, eLM_LaneBody); // settings M timer_deep - if( errmsg != NULL) + if( errmsg != nullptr) { return luaL_error( L, errmsg); } @@ -2011,7 +2011,7 @@ LUAG_FUNC( configure) // because we will do it after on_state_create() is called, // and we don't want to skip _G because of caching in case globals are created then lua_pushglobaltable( L); // settings M _G - populate_func_lookup_table( L, -1, NULL); + populate_func_lookup_table( L, -1, nullptr); lua_pop( L, 1); // settings M } lua_pop( L, 1); // settings diff --git a/src/lanes_private.h b/src/lanes_private.h index 67c99f7..f0d01ac 100644 --- a/src/lanes_private.h +++ b/src/lanes_private.h @@ -35,7 +35,7 @@ struct s_Lane SIGNAL_T* volatile waiting_on; // - // When status is WAITING, points on the linda's signal the thread waits on, else NULL + // When status is WAITING, points on the linda's signal the thread waits on, else nullptr volatile enum e_cancel_request cancel_request; // @@ -61,9 +61,9 @@ struct s_Lane struct s_Lane* volatile selfdestruct_next; // - // M: sets to non-NULL if facing lane handle '__gc' cycle but the lane + // M: sets to non-nullptr if facing lane handle '__gc' cycle but the lane // is still running - // S: cleans up after itself if non-NULL at lane exit + // S: cleans up after itself if non-nullptr at lane exit #if HAVE_LANE_TRACKING() struct s_Lane* volatile tracking_next; diff --git a/src/linda.cpp b/src/linda.cpp index eac6458..5832f22 100644 --- a/src/linda.cpp +++ b/src/linda.cpp @@ -63,7 +63,7 @@ static void* linda_id( lua_State*, DeepOp); static inline struct s_Linda* lua_toLinda( lua_State* L, int idx_) { struct s_Linda* linda = (struct s_Linda*) luaG_todeep( L, linda_id, idx_); - luaL_argcheck( L, linda != NULL, idx_, "expecting a linda object"); + luaL_argcheck( L, linda != nullptr, idx_, "expecting a linda object"); return linda; } @@ -88,8 +88,8 @@ LUAG_FUNC( linda_protected_call) // acquire the keeper Keeper* K = keeper_acquire( linda->U->keepers, LINDA_KEEPER_HASHSEED(linda)); - lua_State* KL = K ? K->L : NULL; // need to do this for 'STACK_CHECK' - if( KL == NULL) return 0; + lua_State* KL = K ? K->L : nullptr; // need to do this for 'STACK_CHECK' + if( KL == nullptr) return 0; // retrieve the actual function to be called and move it before the arguments lua_pushvalue( L, lua_upvalueindex( 1)); @@ -171,12 +171,12 @@ LUAG_FUNC( linda_send) bool_t try_again = TRUE; Lane* const s = get_lane_from_registry( L); Keeper* K = which_keeper( linda->U->keepers, LINDA_KEEPER_HASHSEED( linda)); - lua_State* KL = K ? K->L : NULL; // need to do this for 'STACK_CHECK' - if( KL == NULL) return 0; + lua_State* KL = K ? K->L : nullptr; // need to do this for 'STACK_CHECK' + if( KL == nullptr) return 0; STACK_CHECK( KL, 0); for( ;;) { - if( s != NULL) + if( s != nullptr) { cancel = s->cancel_request; } @@ -215,20 +215,20 @@ LUAG_FUNC( linda_send) // storage limit hit, wait until timeout or signalled that we should try again { enum e_status prev_status = ERROR_ST; // prevent 'might be used uninitialized' warnings - if( s != NULL) + if( s != nullptr) { // change status of lane to "waiting" prev_status = s->status; // RUNNING, most likely ASSERT_L( prev_status == RUNNING); // but check, just in case s->status = WAITING; - ASSERT_L( s->waiting_on == NULL); + ASSERT_L( s->waiting_on == nullptr); s->waiting_on = &linda->read_happened; } // could not send because no room: wait until some data was read before trying again, or until timeout is reached try_again = SIGNAL_WAIT( &linda->read_happened, &K->keeper_cs, timeout); - if( s != NULL) + if( s != nullptr) { - s->waiting_on = NULL; + s->waiting_on = nullptr; s->status = prev_status; } } @@ -331,10 +331,10 @@ LUAG_FUNC( linda_receive) bool_t try_again = TRUE; Lane* const s = get_lane_from_registry( L); Keeper* K = which_keeper( linda->U->keepers, LINDA_KEEPER_HASHSEED( linda)); - if( K == NULL) return 0; + if( K == nullptr) return 0; for( ;;) { - if( s != NULL) + if( s != nullptr) { cancel = s->cancel_request; } @@ -371,20 +371,20 @@ LUAG_FUNC( linda_receive) // nothing received, wait until timeout or signalled that we should try again { enum e_status prev_status = ERROR_ST; // prevent 'might be used uninitialized' warnings - if( s != NULL) + if( s != nullptr) { // change status of lane to "waiting" prev_status = s->status; // RUNNING, most likely ASSERT_L( prev_status == RUNNING); // but check, just in case s->status = WAITING; - ASSERT_L( s->waiting_on == NULL); + ASSERT_L( s->waiting_on == nullptr); s->waiting_on = &linda->write_happened; } // not enough data to read: wakeup when data was sent, or when timeout is reached try_again = SIGNAL_WAIT( &linda->write_happened, &K->keeper_cs, timeout); - if( s != NULL) + if( s != nullptr) { - s->waiting_on = NULL; + s->waiting_on = nullptr; s->status = prev_status; } } @@ -654,7 +654,7 @@ static int linda_tostring( lua_State* L, int idx_, bool_t opt_) { luaL_argcheck( L, linda, idx_, "expecting a linda object"); } - if( linda != NULL) + if( linda != nullptr) { char text[128]; int len; @@ -764,7 +764,7 @@ static void* linda_id( lua_State* L, DeepOp op_) { struct s_Linda* s; size_t name_len = 0; - char const* linda_name = NULL; + char const* linda_name = nullptr; unsigned long linda_group = 0; // should have a string and/or a number of the stack as parameters (name and group) switch( lua_gettop( L)) @@ -797,7 +797,7 @@ static void* linda_id( lua_State* L, DeepOp op_) { Universe* const U = universe_get(L); AllocatorDefinition* const allocD = &U->internal_allocator; - s = (struct s_Linda*) allocD->allocF(allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included + s = (struct s_Linda*) allocD->allocF(allocD->allocUD, nullptr, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included } if( s) { @@ -821,7 +821,7 @@ static void* linda_id( lua_State* L, DeepOp op_) // Clean associated structures in the keeper state. K = keeper_acquire( linda->U->keepers, LINDA_KEEPER_HASHSEED( linda)); - if( K && K->L) // can be NULL if this happens during main state shutdown (lanes is GC'ed -> no keepers -> no need to cleanup) + if( K && K->L) // can be nullptr if this happens during main state shutdown (lanes is GC'ed -> no keepers -> no need to cleanup) { // hopefully this won't ever raise an error as we would jump to the closest pcall site while forgetting to release the keeper mutex... keeper_call( linda->U, K->L, KEEPER_API( clear), L, linda, 0); @@ -836,7 +836,7 @@ static void* linda_id( lua_State* L, DeepOp op_) AllocatorDefinition* const allocD = &U->internal_allocator; (void) allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0); } - return NULL; + return nullptr; } case eDO_metatable: @@ -908,7 +908,7 @@ static void* linda_id( lua_State* L, DeepOp op_) lua_setfield( L, -2, "null"); STACK_END( L, 1); - return NULL; + return nullptr; } case eDO_module: @@ -917,7 +917,7 @@ static void* linda_id( lua_State* L, DeepOp op_) // in other words, forever. default: { - return NULL; + return nullptr; } } } diff --git a/src/universe.cpp b/src/universe.cpp index 0a014f7..d5cc9e2 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -56,7 +56,7 @@ Universe* universe_create( lua_State* L) void universe_store( lua_State* L, Universe* U) { STACK_CHECK( L, 0); - REGISTRY_SET( L, UNIVERSE_REGKEY, (NULL != U) ? lua_pushlightuserdata( L, U) : lua_pushnil( L)); + REGISTRY_SET( L, UNIVERSE_REGKEY, (nullptr != U) ? lua_pushlightuserdata( L, U) : lua_pushnil( L)); STACK_END( L, 0); } -- cgit v1.2.3-55-g6feb