diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-11-10 10:21:55 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-11-10 10:31:35 +0100 |
commit | 26f05d59bc1c25b8a0d19be7f4738fd12e557001 (patch) | |
tree | 560cccfaacf4b63385aa52ac4b3912248e87cbef /sal/rtl | |
parent | 5bbdb9423e15b68438bb8397c15635e044129e28 (diff) |
loplugin:nullptr (automatic rewrite)
Change-Id: I1bc6c87fcd6e5e96362623be94c59be216a3b2b8
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/alloc_arena.cxx | 112 | ||||
-rw-r--r-- | sal/rtl/alloc_cache.cxx | 232 | ||||
-rw-r--r-- | sal/rtl/alloc_global.cxx | 46 | ||||
-rw-r--r-- | sal/rtl/alloc_impl.hxx | 2 | ||||
-rw-r--r-- | sal/rtl/bootstrap.cxx | 70 | ||||
-rw-r--r-- | sal/rtl/byteseq.cxx | 20 | ||||
-rw-r--r-- | sal/rtl/cipher.cxx | 30 | ||||
-rw-r--r-- | sal/rtl/cmdargs.cxx | 6 | ||||
-rw-r--r-- | sal/rtl/digest.cxx | 40 | ||||
-rw-r--r-- | sal/rtl/hash.cxx | 28 | ||||
-rw-r--r-- | sal/rtl/locale.cxx | 30 | ||||
-rw-r--r-- | sal/rtl/math.cxx | 8 | ||||
-rw-r--r-- | sal/rtl/random.cxx | 4 | ||||
-rw-r--r-- | sal/rtl/rtl_process.cxx | 2 | ||||
-rw-r--r-- | sal/rtl/strbuf.cxx | 2 | ||||
-rw-r--r-- | sal/rtl/string.cxx | 28 | ||||
-rw-r--r-- | sal/rtl/strtmpl.cxx | 22 | ||||
-rw-r--r-- | sal/rtl/uri.cxx | 8 | ||||
-rw-r--r-- | sal/rtl/ustrbuf.cxx | 4 | ||||
-rw-r--r-- | sal/rtl/ustring.cxx | 102 | ||||
-rw-r--r-- | sal/rtl/uuid.cxx | 6 |
21 files changed, 401 insertions, 401 deletions
diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx index 329d013dfafb..3e6adbe481ab 100644 --- a/sal/rtl/alloc_arena.cxx +++ b/sal/rtl/alloc_arena.cxx @@ -50,7 +50,7 @@ static rtl_arena_list_st g_arena_list; * * @internal */ -static rtl_arena_type * gp_arena_arena = 0; +static rtl_arena_type * gp_arena_arena = nullptr; /** gp_machdep_arena * @@ -59,11 +59,11 @@ static rtl_arena_type * gp_arena_arena = 0; * * @internal */ -static rtl_arena_type * gp_machdep_arena = 0; +static rtl_arena_type * gp_machdep_arena = nullptr; /** gp_default_arena */ -rtl_arena_type * gp_default_arena = 0; +rtl_arena_type * gp_default_arena = nullptr; namespace { @@ -127,7 +127,7 @@ rtl_arena_segment_populate ( span = static_cast< rtl_arena_segment_type * >( rtl_machdep_alloc(gp_machdep_arena, &size)); - if (span != 0) + if (span != nullptr) { rtl_arena_segment_type *first, *last, *head; sal_Size count = size / sizeof(rtl_arena_segment_type); @@ -150,7 +150,7 @@ rtl_arena_segment_populate ( first->m_type = 0; } } - return (span != 0); + return (span != nullptr); } /** rtl_arena_segment_get() @@ -166,7 +166,7 @@ rtl_arena_segment_get ( { rtl_arena_segment_type * head; - assert(*ppSegment == 0); + assert(*ppSegment == nullptr); head = &(arena->m_segment_reserve_head); if ((head->m_snext != head) || rtl_arena_segment_populate (arena)) @@ -203,7 +203,7 @@ rtl_arena_segment_put ( QUEUE_INSERT_HEAD_NAMED(head, (*ppSegment), s); /* clear */ - (*ppSegment) = 0; + (*ppSegment) = nullptr; } /** rtl_arena_freelist_insert() @@ -274,7 +274,7 @@ rtl_arena_hash_rescale ( new_bytes = new_size * sizeof(rtl_arena_segment_type*); new_table = static_cast<rtl_arena_segment_type **>(rtl_arena_alloc (gp_arena_arena, &new_bytes)); - if (new_table != 0) + if (new_table != nullptr) { rtl_arena_segment_type ** old_table; sal_Size old_size, i; @@ -302,7 +302,7 @@ rtl_arena_hash_rescale ( for (i = 0; i < old_size; i++) { rtl_arena_segment_type * curr = old_table[i]; - while (curr != 0) + while (curr != nullptr) { rtl_arena_segment_type * next = curr->m_fnext; rtl_arena_segment_type ** head; @@ -314,7 +314,7 @@ rtl_arena_hash_rescale ( curr = next; } - old_table[i] = 0; + old_table[i] = nullptr; } RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); @@ -361,7 +361,7 @@ rtl_arena_hash_remove ( sal_Size lookups = 0; segpp = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, addr)]); - while ((segment = *segpp) != 0) + while ((segment = *segpp) != nullptr) { if (segment->m_addr == addr) { @@ -374,8 +374,8 @@ rtl_arena_hash_remove ( segpp = &(segment->m_fnext); } - assert(segment != 0); // bad free - if (segment != 0) + assert(segment != nullptr); // bad free + if (segment != nullptr) { assert(segment->m_size == size); (void) size; // avoid warnings @@ -424,7 +424,7 @@ rtl_arena_segment_alloc ( { int index = 0; - assert(*ppSegment == 0); + assert(*ppSegment == nullptr); if (!RTL_MEMORY_ISP2(size)) { int msb = highbit(size); @@ -462,12 +462,12 @@ rtl_arena_segment_alloc ( } dequeue_and_leave: - if (*ppSegment != 0) + if (*ppSegment != nullptr) { /* remove from freelist */ rtl_arena_freelist_remove (arena, (*ppSegment)); } - return (*ppSegment != 0); + return (*ppSegment != nullptr); } /** rtl_arena_segment_create() @@ -483,15 +483,15 @@ rtl_arena_segment_create ( rtl_arena_segment_type ** ppSegment ) { - assert((*ppSegment) == 0); - if (arena->m_source_alloc != 0) + assert((*ppSegment) == nullptr); + if (arena->m_source_alloc != nullptr) { rtl_arena_segment_get (arena, ppSegment); - if (*ppSegment != 0) + if (*ppSegment != nullptr) { - rtl_arena_segment_type * span = 0; + rtl_arena_segment_type * span = nullptr; rtl_arena_segment_get (arena, &span); - if (span != 0) + if (span != nullptr) { /* import new span from source arena */ RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock)); @@ -679,8 +679,8 @@ rtl_arena_activate ( void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size) ) { - assert(arena != 0); - if (arena != 0) + assert(arena != nullptr); + if (arena != nullptr) { (void) snprintf (arena->m_name, sizeof(arena->m_name), "%s", name); @@ -709,13 +709,13 @@ rtl_arena_activate ( if (!(arena->m_qcache_ptr)) { /* out of memory */ - return 0; + return nullptr; } for (i = 1; i <= n; i++) { size = i * arena->m_quantum; (void) snprintf (namebuf, sizeof(namebuf), "%s_%" SAL_PRIuUINTPTR, arena->m_name, size); - arena->m_qcache_ptr[i - 1] = rtl_cache_create(namebuf, size, 0, NULL, NULL, NULL, NULL, arena, RTL_CACHE_FLAG_QUANTUMCACHE); + arena->m_qcache_ptr[i - 1] = rtl_cache_create(namebuf, size, 0, nullptr, nullptr, nullptr, nullptr, arena, RTL_CACHE_FLAG_QUANTUMCACHE); } } @@ -742,15 +742,15 @@ rtl_arena_deactivate ( RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock)); /* cleanup quantum cache(s) */ - if ((arena->m_qcache_max > 0) && (arena->m_qcache_ptr != 0)) + if ((arena->m_qcache_max > 0) && (arena->m_qcache_ptr != nullptr)) { int i, n = (arena->m_qcache_max >> arena->m_quantum_shift); for (i = 1; i <= n; i++) { - if (arena->m_qcache_ptr[i - 1] != 0) + if (arena->m_qcache_ptr[i - 1] != nullptr) { rtl_cache_destroy (arena->m_qcache_ptr[i - 1]); - arena->m_qcache_ptr[i - 1] = 0; + arena->m_qcache_ptr[i - 1] = nullptr; } } rtl_arena_free ( @@ -758,7 +758,7 @@ rtl_arena_deactivate ( arena->m_qcache_ptr, n * sizeof(rtl_cache_type*)); - arena->m_qcache_ptr = 0; + arena->m_qcache_ptr = nullptr; } /* check for leaked segments */ @@ -782,7 +782,7 @@ rtl_arena_deactivate ( /* cleanup still used segment(s) */ for (i = 0, n = arena->m_hash_size; i < n; i++) { - while ((segment = arena->m_hash_table[i]) != 0) + while ((segment = arena->m_hash_table[i]) != nullptr) { /* pop from hash table */ arena->m_hash_table[i] = segment->m_fnext, segment->m_fnext = segment->m_fprev = segment; @@ -874,19 +874,19 @@ SAL_CALL rtl_arena_create ( SAL_UNUSED_PARAMETER int ) SAL_THROW_EXTERN_C() { - rtl_arena_type * result = 0; + rtl_arena_type * result = nullptr; sal_Size size = sizeof(rtl_arena_type); try_alloc: result = static_cast<rtl_arena_type*>(rtl_arena_alloc (gp_arena_arena, &size)); - if (result != 0) + if (result != nullptr) { rtl_arena_type * arena = result; rtl_arena_constructor (arena); if (!source_arena) { - assert(gp_default_arena != 0); + assert(gp_default_arena != nullptr); source_arena = gp_default_arena; } @@ -900,14 +900,14 @@ try_alloc: source_free ); - if (result == 0) + if (result == nullptr) { rtl_arena_deactivate (arena); rtl_arena_destructor (arena); rtl_arena_free (gp_arena_arena, arena, size); } } - else if (gp_arena_arena == 0) + else if (gp_arena_arena == nullptr) { ensureArenaSingleton(); if (gp_arena_arena) @@ -926,7 +926,7 @@ SAL_CALL rtl_arena_destroy ( rtl_arena_type * arena ) SAL_THROW_EXTERN_C() { - if (arena != 0) + if (arena != nullptr) { rtl_arena_deactivate (arena); rtl_arena_destructor (arena); @@ -942,9 +942,9 @@ SAL_CALL rtl_arena_alloc ( sal_Size * pSize ) SAL_THROW_EXTERN_C() { - void * addr = 0; + void * addr = nullptr; - if ((arena != 0) && (pSize != 0)) + if ((arena != nullptr) && (pSize != nullptr)) { sal_Size size; @@ -952,7 +952,7 @@ SAL_CALL rtl_arena_alloc ( if (size > arena->m_qcache_max) { /* allocate from segment list */ - rtl_arena_segment_type *segment = 0; + rtl_arena_segment_type *segment = nullptr; RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); if (rtl_arena_segment_alloc (arena, size, &segment) || @@ -970,9 +970,9 @@ SAL_CALL rtl_arena_alloc ( oversize = segment->m_size - size; if ((oversize >= arena->m_quantum) && (oversize >= arena->m_qcache_max)) { - rtl_arena_segment_type * remainder = 0; + rtl_arena_segment_type * remainder = nullptr; rtl_arena_segment_get (arena, &remainder); - if (remainder != 0) + if (remainder != nullptr) { segment->m_size = size; @@ -996,10 +996,10 @@ SAL_CALL rtl_arena_alloc ( { /* allocate from quantum cache(s) */ int index = (size >> arena->m_quantum_shift) - 1; - assert(arena->m_qcache_ptr[index] != 0); + assert(arena->m_qcache_ptr[index] != nullptr); addr = rtl_cache_alloc (arena->m_qcache_ptr[index]); - if (addr != 0) + if (addr != nullptr) (*pSize) = size; } } @@ -1015,7 +1015,7 @@ SAL_CALL rtl_arena_free ( sal_Size size ) SAL_THROW_EXTERN_C() { - if (arena != 0) + if (arena != nullptr) { size = RTL_MEMORY_ALIGN(size, arena->m_quantum); if (size > arena->m_qcache_max) @@ -1026,7 +1026,7 @@ SAL_CALL rtl_arena_free ( RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock)); segment = rtl_arena_hash_remove (arena, reinterpret_cast<sal_uIntPtr>(addr), size); - if (segment != 0) + if (segment != nullptr) { rtl_arena_segment_type *next, *prev; @@ -1081,7 +1081,7 @@ SAL_CALL rtl_arena_free ( { /* free to quantum cache(s) */ int index = (size >> arena->m_quantum_shift) - 1; - assert(arena->m_qcache_ptr[index] != 0); + assert(arena->m_qcache_ptr[index] != nullptr); rtl_cache_free (arena->m_qcache_ptr[index], addr); } @@ -1139,7 +1139,7 @@ SAL_CALL rtl_machdep_alloc ( #endif #if defined(SAL_UNX) - addr = mmap (NULL, (size_t)(size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); + addr = mmap (nullptr, (size_t)(size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); #elif defined(SAL_W32) addr = VirtualAlloc (NULL, (SIZE_T)(size), MEM_COMMIT, PAGE_READWRITE); #endif /* (SAL_UNX || SAL_W32) */ @@ -1153,7 +1153,7 @@ SAL_CALL rtl_machdep_alloc ( (*pSize) = size; return addr; } - return NULL; + return nullptr; } /** rtl_machdep_free() @@ -1214,7 +1214,7 @@ rtl_arena_init() /* machdep (pseudo) arena */ static rtl_arena_type g_machdep_arena; - assert(gp_machdep_arena == 0); + assert(gp_machdep_arena == nullptr); rtl_arena_constructor (&g_machdep_arena); gp_machdep_arena = rtl_arena_activate ( @@ -1222,15 +1222,15 @@ rtl_arena_init() "rtl_machdep_arena", rtl_machdep_pagesize(), 0, /* no quantum caching */ - 0, 0, 0 /* no source */ + nullptr, nullptr, nullptr /* no source */ ); - assert(gp_machdep_arena != 0); + assert(gp_machdep_arena != nullptr); } { /* default arena */ static rtl_arena_type g_default_arena; - assert(gp_default_arena == 0); + assert(gp_default_arena == nullptr); rtl_arena_constructor (&g_default_arena); gp_default_arena = rtl_arena_activate ( @@ -1242,13 +1242,13 @@ rtl_arena_init() rtl_machdep_alloc, rtl_machdep_free ); - assert(gp_default_arena != 0); + assert(gp_default_arena != nullptr); } { /* arena internal arena */ static rtl_arena_type g_arena_arena; - assert(gp_arena_arena == 0); + assert(gp_arena_arena == nullptr); rtl_arena_constructor (&g_arena_arena); gp_arena_arena = rtl_arena_activate ( @@ -1260,7 +1260,7 @@ rtl_arena_init() rtl_arena_alloc, rtl_arena_free ); - assert(gp_arena_arena != 0); + assert(gp_arena_arena != nullptr); } // SAL_INFO("sal.rtl", "rtl_arena_init completed"); } @@ -1270,7 +1270,7 @@ rtl_arena_init() void rtl_arena_fini() { - if (gp_arena_arena != 0) + if (gp_arena_arena != nullptr) { rtl_arena_type * arena, * head; diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx index 8a80e70fba1b..54903819e93c 100644 --- a/sal/rtl/alloc_cache.cxx +++ b/sal/rtl/alloc_cache.cxx @@ -62,22 +62,22 @@ static rtl_cache_list_st g_cache_list; * * @internal */ -static rtl_arena_type * gp_cache_arena = 0; +static rtl_arena_type * gp_cache_arena = nullptr; /** gp_cache_magazine_cache * @internal */ -static rtl_cache_type * gp_cache_magazine_cache = 0; +static rtl_cache_type * gp_cache_magazine_cache = nullptr; /** gp_cache_slab_cache * @internal */ -static rtl_cache_type * gp_cache_slab_cache = 0; +static rtl_cache_type * gp_cache_slab_cache = nullptr; /** gp_cache_bufctl_cache * @internal */ -static rtl_cache_type * gp_cache_bufctl_cache = 0; +static rtl_cache_type * gp_cache_bufctl_cache = nullptr; /* ================================================================= */ @@ -104,7 +104,7 @@ rtl_cache_hash_rescale ( new_bytes = new_size * sizeof(rtl_cache_bufctl_type*); new_table = static_cast<rtl_cache_bufctl_type**>(rtl_arena_alloc(gp_cache_arena, &new_bytes)); - if (new_table != 0) + if (new_table != nullptr) { rtl_cache_bufctl_type ** old_table; sal_Size old_size, i; @@ -133,7 +133,7 @@ rtl_cache_hash_rescale ( for (i = 0; i < old_size; i++) { rtl_cache_bufctl_type * curr = old_table[i]; - while (curr != 0) + while (curr != nullptr) { rtl_cache_bufctl_type * next = curr->m_next; rtl_cache_bufctl_type ** head; @@ -145,7 +145,7 @@ rtl_cache_hash_rescale ( curr = next; } - old_table[i] = 0; + old_table[i] = nullptr; } RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); @@ -187,11 +187,11 @@ rtl_cache_hash_remove ( sal_Size lookups = 0; ppHead = &(cache->m_hash_table[RTL_CACHE_HASH_INDEX(cache, addr)]); - while ((bufctl = *ppHead) != 0) + while ((bufctl = *ppHead) != nullptr) { if (bufctl->m_addr == addr) { - *ppHead = bufctl->m_next, bufctl->m_next = 0; + *ppHead = bufctl->m_next, bufctl->m_next = nullptr; break; } @@ -199,7 +199,7 @@ rtl_cache_hash_remove ( ppHead = &(bufctl->m_next); } - assert(bufctl != 0); // bad free + assert(bufctl != nullptr); // bad free if (lookups > 1) { @@ -264,13 +264,13 @@ rtl_cache_slab_create ( rtl_cache_type * cache ) { - rtl_cache_slab_type * slab = 0; + rtl_cache_slab_type * slab = nullptr; void * addr; sal_Size size; size = cache->m_slab_size; addr = rtl_arena_alloc (cache->m_source, &size); - if (addr != 0) + if (addr != nullptr) { assert(size >= cache->m_slab_size); @@ -284,15 +284,15 @@ rtl_cache_slab_create ( { /* construct embedded slab struct */ slab = RTL_CACHE_SLAB(addr, cache->m_slab_size); - (void) rtl_cache_slab_constructor (slab, 0); + (void) rtl_cache_slab_constructor (slab, nullptr); } - if (slab != 0) + if (slab != nullptr) { slab->m_data = reinterpret_cast<sal_uIntPtr>(addr); /* dynamic freelist initialization */ slab->m_bp = slab->m_data; - slab->m_sp = 0; + slab->m_sp = nullptr; } else { @@ -319,12 +319,12 @@ rtl_cache_slab_destroy ( { /* cleanup bufctl(s) for free buffer(s) */ sal_Size ntypes = (slab->m_bp - slab->m_data) / cache->m_type_size; - for (ntypes -= refcnt; slab->m_sp != 0; ntypes--) + for (ntypes -= refcnt; slab->m_sp != nullptr; ntypes--) { rtl_cache_bufctl_type * bufctl = slab->m_sp; /* pop from freelist */ - slab->m_sp = bufctl->m_next, bufctl->m_next = 0; + slab->m_sp = bufctl->m_next, bufctl->m_next = nullptr; /* return bufctl struct to bufctl cache */ rtl_cache_free (gp_cache_bufctl_cache, bufctl); @@ -337,7 +337,7 @@ rtl_cache_slab_destroy ( else { /* destruct embedded slab struct */ - rtl_cache_slab_destructor (slab, 0); + rtl_cache_slab_destructor (slab, nullptr); } if ((refcnt == 0) || (cache->m_features & RTL_CACHE_FEATURE_BULKDESTROY)) @@ -361,7 +361,7 @@ rtl_cache_slab_populate ( RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); slab = rtl_cache_slab_create (cache); RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); - if (slab != 0) + if (slab != nullptr) { /* update buffer start addr w/ current color */ slab->m_bp += cache->m_ncolor; @@ -377,7 +377,7 @@ rtl_cache_slab_populate ( /* insert onto 'free' queue */ QUEUE_INSERT_HEAD_NAMED(&(cache->m_free_head), slab, slab_); } - return (slab != 0); + return (slab != nullptr); } /* ================================================================= */ @@ -391,7 +391,7 @@ rtl_cache_slab_alloc ( rtl_cache_type * cache ) { - void * addr = 0; + void * addr = nullptr; rtl_cache_slab_type * head; RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); @@ -405,7 +405,7 @@ rtl_cache_slab_alloc ( slab = head->m_slab_next; assert(slab->m_ntypes < cache->m_ntypes); - if (slab->m_sp == 0) + if (slab->m_sp == nullptr) { /* initialize bufctl w/ current 'slab->m_bp' */ assert(slab->m_bp < slab->m_data + cache->m_ntypes * cache->m_type_size + cache->m_ncolor_max); @@ -414,11 +414,11 @@ rtl_cache_slab_alloc ( /* allocate bufctl */ assert(cache != gp_cache_bufctl_cache); bufctl = static_cast<rtl_cache_bufctl_type*>(rtl_cache_alloc (gp_cache_bufctl_cache)); - if (bufctl == 0) + if (bufctl == nullptr) { /* out of memory */ RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); - return 0; + return nullptr; } bufctl->m_addr = slab->m_bp; @@ -429,7 +429,7 @@ rtl_cache_slab_alloc ( /* embedded bufctl */ bufctl = reinterpret_cast<rtl_cache_bufctl_type*>(slab->m_bp); } - bufctl->m_next = 0; + bufctl->m_next = nullptr; /* update 'slab->m_bp' to next free buffer */ slab->m_bp += cache->m_type_size; @@ -485,7 +485,7 @@ rtl_cache_slab_free ( if (cache->m_features & RTL_CACHE_FEATURE_HASH) { bufctl = rtl_cache_hash_remove (cache, reinterpret_cast<sal_uIntPtr>(addr)); - slab = (bufctl != 0) ? reinterpret_cast<rtl_cache_slab_type*>(bufctl->m_slab) : 0; + slab = (bufctl != nullptr) ? reinterpret_cast<rtl_cache_slab_type*>(bufctl->m_slab) : nullptr; } else { @@ -494,7 +494,7 @@ rtl_cache_slab_free ( slab = RTL_CACHE_SLAB(addr, cache->m_slab_size); } - if (slab != 0) + if (slab != nullptr) { /* check for full slab */ if (slab->m_ntypes == cache->m_ntypes) @@ -543,7 +543,7 @@ rtl_cache_magazine_constructor (void * obj, SAL_UNUSED_PARAMETER void *) rtl_cache_magazine_type * mag = static_cast<rtl_cache_magazine_type*>(obj); /* @@@ sal_Size size = (sal_Size)(arg); @@@ */ - mag->m_mag_next = 0; + mag->m_mag_next = nullptr; mag->m_mag_size = RTL_CACHE_MAGAZINE_SIZE; mag->m_mag_used = 0; @@ -557,7 +557,7 @@ rtl_cache_magazine_destructor (void * obj, SAL_UNUSED_PARAMETER void *) { rtl_cache_magazine_type * mag = static_cast< rtl_cache_magazine_type * >( obj); - assert(mag->m_mag_next == 0); // assure removed from queue(s) + assert(mag->m_mag_next == nullptr); // assure removed from queue(s) assert(mag->m_mag_used == 0); // assure no longer referenced (void) mag; // avoid warnings } @@ -573,9 +573,9 @@ rtl_cache_magazine_clear ( for (; mag->m_mag_used > 0; --mag->m_mag_used) { void * obj = mag->m_objects[mag->m_mag_used - 1]; - mag->m_objects[mag->m_mag_used - 1] = 0; + mag->m_objects[mag->m_mag_used - 1] = nullptr; - if (cache->m_destructor != 0) + if (cache->m_destructor != nullptr) { /* destruct object */ (cache->m_destructor)(obj, cache->m_userarg); @@ -615,15 +615,15 @@ rtl_cache_depot_dequeue ( rtl_cache_depot_type * depot ) { - rtl_cache_magazine_type * mag = 0; + rtl_cache_magazine_type * mag = nullptr; if (depot->m_mag_count > 0) { /* dequeue magazine */ - assert(depot->m_mag_next != 0); + assert(depot->m_mag_next != nullptr); mag = depot->m_mag_next; depot->m_mag_next = mag->m_mag_next; - mag->m_mag_next = 0; + mag->m_mag_next = nullptr; /* update depot stats */ depot->m_mag_count--; @@ -647,17 +647,17 @@ rtl_cache_depot_exchange_alloc ( { rtl_cache_magazine_type * full; - assert((empty == 0) || (empty->m_mag_used == 0)); + assert((empty == nullptr) || (empty->m_mag_used == 0)); /* dequeue full magazine */ full = rtl_cache_depot_dequeue (&(cache->m_depot_full)); - if ((full != 0) && (empty != 0)) + if ((full != nullptr) && (empty != nullptr)) { /* enqueue empty magazine */ rtl_cache_depot_enqueue (&(cache->m_depot_empty), empty); } - assert((full == 0) || (full->m_mag_used > 0)); + assert((full == nullptr) || (full->m_mag_used > 0)); return full; } @@ -674,17 +674,17 @@ rtl_cache_depot_exchange_free ( { rtl_cache_magazine_type * empty; - assert((full == 0) || (full->m_mag_used > 0)); + assert((full == nullptr) || (full->m_mag_used > 0)); /* dequeue empty magazine */ empty = rtl_cache_depot_dequeue (&(cache->m_depot_empty)); - if ((empty != 0) && (full != 0)) + if ((empty != nullptr) && (full != nullptr)) { /* enqueue full magazine */ rtl_cache_depot_enqueue (&(cache->m_depot_full), full); } - assert((empty == 0) || (empty->m_mag_used == 0)); + assert((empty == nullptr) || (empty->m_mag_used == 0)); return empty; } @@ -698,21 +698,21 @@ rtl_cache_depot_populate ( rtl_cache_type * cache ) { - rtl_cache_magazine_type * empty = 0; + rtl_cache_magazine_type * empty = nullptr; - if (cache->m_magazine_cache != 0) + if (cache->m_magazine_cache != nullptr) { /* allocate new empty magazine */ RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); empty = static_cast<rtl_cache_magazine_type*>(rtl_cache_alloc (cache->m_magazine_cache)); RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); - if (empty != 0) + if (empty != nullptr) { /* enqueue (new) empty magazine */ rtl_cache_depot_enqueue (&(cache->m_depot_empty), empty); } } - return (empty != 0); + return (empty != nullptr); } /* ================================================================= */ @@ -787,8 +787,8 @@ rtl_cache_activate ( int flags ) { - assert(cache != 0); - if (cache != 0) + assert(cache != nullptr); + if (cache != nullptr) { sal_Size slabsize; @@ -855,8 +855,8 @@ rtl_cache_activate ( if (cache->m_slab_size > source->m_quantum) { - assert(gp_cache_slab_cache != 0); - assert(gp_cache_bufctl_cache != 0); + assert(gp_cache_slab_cache != nullptr); + assert(gp_cache_bufctl_cache != nullptr); cache->m_features |= RTL_CACHE_FEATURE_HASH; cache->m_ntypes = cache->m_slab_size / cache->m_type_size; @@ -881,7 +881,7 @@ rtl_cache_activate ( /* magazine layer */ if (!(flags & RTL_CACHE_FLAG_NOMAGAZINE)) { - assert(gp_cache_magazine_cache != 0); + assert(gp_cache_magazine_cache != nullptr); cache->m_magazine_cache = gp_cache_magazine_cache; } @@ -910,37 +910,37 @@ rtl_cache_deactivate ( (void)active; /* cleanup magazine layer */ - if (cache->m_magazine_cache != 0) + if (cache->m_magazine_cache != nullptr) { rtl_cache_type * mag_cache; rtl_cache_magazine_type * mag; /* prevent recursion */ - mag_cache = cache->m_magazine_cache, cache->m_magazine_cache = 0; + mag_cache = cache->m_magazine_cache, cache->m_magazine_cache = nullptr; /* cleanup cpu layer */ - if ((mag = cache->m_cpu_curr) != 0) + if ((mag = cache->m_cpu_curr) != nullptr) { // coverity[missing_lock] - cache->m_cpu_curr = 0; + cache->m_cpu_curr = nullptr; rtl_cache_magazine_clear (cache, mag); rtl_cache_free (mag_cache, mag); } - if ((mag = cache->m_cpu_prev) != 0) + if ((mag = cache->m_cpu_prev) != nullptr) { // coverity[missing_lock] - cache->m_cpu_prev = 0; + cache->m_cpu_prev = nullptr; rtl_cache_magazine_clear (cache, mag); rtl_cache_free (mag_cache, mag); } /* cleanup depot layer */ - while ((mag = rtl_cache_depot_dequeue(&(cache->m_depot_full))) != 0) + while ((mag = rtl_cache_depot_dequeue(&(cache->m_depot_full))) != nullptr) { rtl_cache_magazine_clear (cache, mag); rtl_cache_free (mag_cache, mag); } - while ((mag = rtl_cache_depot_dequeue(&(cache->m_depot_empty))) != 0) + while ((mag = rtl_cache_depot_dequeue(&(cache->m_depot_empty))) != nullptr) { rtl_cache_magazine_clear (cache, mag); rtl_cache_free (mag_cache, mag); @@ -977,10 +977,10 @@ rtl_cache_deactivate ( for (i = 0; i < n; i++) { rtl_cache_bufctl_type * bufctl; - while ((bufctl = cache->m_hash_table[i]) != 0) + while ((bufctl = cache->m_hash_table[i]) != nullptr) { /* pop from hash table */ - cache->m_hash_table[i] = bufctl->m_next, bufctl->m_next = 0; + cache->m_hash_table[i] = bufctl->m_next, bufctl->m_next = nullptr; /* return to bufctl cache */ rtl_cache_free (gp_cache_bufctl_cache, bufctl); @@ -1055,12 +1055,12 @@ SAL_CALL rtl_cache_create ( int flags ) SAL_THROW_EXTERN_C() { - rtl_cache_type * result = 0; + rtl_cache_type * result = nullptr; sal_Size size = sizeof(rtl_cache_type); try_alloc: result = static_cast<rtl_cache_type*>(rtl_arena_alloc (gp_cache_arena, &size)); - if (result != 0) + if (result != nullptr) { rtl_cache_type * cache = result; (void) rtl_cache_constructor (cache); @@ -1068,7 +1068,7 @@ try_alloc: if (!source) { /* use default arena */ - assert(gp_default_arena != 0); + assert(gp_default_arena != nullptr); source = gp_default_arena; } @@ -1085,7 +1085,7 @@ try_alloc: flags ); - if (result == 0) + if (result == nullptr) { /* activation failed */ rtl_cache_deactivate (cache); @@ -1093,7 +1093,7 @@ try_alloc: rtl_arena_free (gp_cache_arena, cache, size); } } - else if (gp_cache_arena == 0) + else if (gp_cache_arena == nullptr) { ensureCacheSingleton(); if (gp_cache_arena) @@ -1111,7 +1111,7 @@ void SAL_CALL rtl_cache_destroy ( rtl_cache_type * cache ) SAL_THROW_EXTERN_C() { - if (cache != 0) + if (cache != nullptr) { rtl_cache_deactivate (cache); rtl_cache_destructor (cache); @@ -1126,27 +1126,27 @@ SAL_CALL rtl_cache_alloc ( rtl_cache_type * cache ) SAL_THROW_EXTERN_C() { - void * obj = 0; + void * obj = nullptr; - if (cache == 0) - return 0; + if (cache == nullptr) + return nullptr; if (alloc_mode == AMode_SYSTEM) { obj = rtl_allocateMemory(cache->m_type_size); - if ((obj != 0) && (cache->m_constructor != 0)) + if ((obj != nullptr) && (cache->m_constructor != nullptr)) { if (!((cache->m_constructor)(obj, cache->m_userarg))) { /* construction failure */ - rtl_freeMemory(obj), obj = 0; + rtl_freeMemory(obj), obj = nullptr; } } return obj; } RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); - if (cache->m_cpu_curr != 0) + if (cache->m_cpu_curr != nullptr) { for (;;) { @@ -1154,7 +1154,7 @@ SAL_CALL rtl_cache_alloc ( rtl_cache_magazine_type *curr, *prev, *temp; curr = cache->m_cpu_curr; - if ((curr != 0) && (curr->m_mag_used > 0)) + if ((curr != nullptr) && (curr->m_mag_used > 0)) { obj = curr->m_objects[--curr->m_mag_used]; cache->m_cpu_stats.m_alloc += 1; @@ -1164,7 +1164,7 @@ SAL_CALL rtl_cache_alloc ( } prev = cache->m_cpu_prev; - if ((prev != 0) && (prev->m_mag_used > 0)) + if ((prev != nullptr) && (prev->m_mag_used > 0)) { temp = cache->m_cpu_curr; cache->m_cpu_curr = cache->m_cpu_prev; @@ -1174,7 +1174,7 @@ SAL_CALL rtl_cache_alloc ( } temp = rtl_cache_depot_exchange_alloc (cache, prev); - if (temp != 0) + if (temp != nullptr) { cache->m_cpu_prev = cache->m_cpu_curr; cache->m_cpu_curr = temp; @@ -1190,13 +1190,13 @@ SAL_CALL rtl_cache_alloc ( /* alloc buffer from slab layer */ obj = rtl_cache_slab_alloc (cache); - if ((obj != 0) && (cache->m_constructor != 0)) + if ((obj != nullptr) && (cache->m_constructor != nullptr)) { /* construct object */ if (!((cache->m_constructor)(obj, cache->m_userarg))) { /* construction failure */ - rtl_cache_slab_free (cache, obj), obj = 0; + rtl_cache_slab_free (cache, obj), obj = nullptr; } } return (obj); @@ -1210,11 +1210,11 @@ SAL_CALL rtl_cache_free ( void * obj ) SAL_THROW_EXTERN_C() { - if ((obj != 0) && (cache != 0)) + if ((obj != nullptr) && (cache != nullptr)) { if (alloc_mode == AMode_SYSTEM) { - if (cache->m_destructor != 0) + if (cache->m_destructor != nullptr) { /* destruct object */ (cache->m_destructor)(obj, cache->m_userarg); @@ -1231,7 +1231,7 @@ SAL_CALL rtl_cache_free ( rtl_cache_magazine_type *curr, *prev, *temp; curr = cache->m_cpu_curr; - if ((curr != 0) && (curr->m_mag_used < curr->m_mag_size)) + if ((curr != nullptr) && (curr->m_mag_used < curr->m_mag_size)) { curr->m_objects[curr->m_mag_used++] = obj; cache->m_cpu_stats.m_free += 1; @@ -1241,7 +1241,7 @@ SAL_CALL rtl_cache_free ( } prev = cache->m_cpu_prev; - if ((prev != 0) && (prev->m_mag_used == 0)) + if ((prev != nullptr) && (prev->m_mag_used == 0)) { temp = cache->m_cpu_curr; cache->m_cpu_curr = cache->m_cpu_prev; @@ -1251,7 +1251,7 @@ SAL_CALL rtl_cache_free ( } temp = rtl_cache_depot_exchange_free (cache, prev); - if (temp != 0) + if (temp != nullptr) { cache->m_cpu_prev = cache->m_cpu_curr; cache->m_cpu_curr = temp; @@ -1271,7 +1271,7 @@ SAL_CALL rtl_cache_free ( RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); /* no space for constructed object in magazine layer */ - if (cache->m_destructor != 0) + if (cache->m_destructor != nullptr) { /* destruct object */ (cache->m_destructor)(obj, cache->m_userarg); @@ -1333,9 +1333,9 @@ rtl_cache_wsupdate_init() { RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); g_cache_list.m_update_done = 0; - (void) pthread_cond_init (&(g_cache_list.m_update_cond), NULL); + (void) pthread_cond_init (&(g_cache_list.m_update_cond), nullptr); if (pthread_create ( - &(g_cache_list.m_update_thread), NULL, rtl_cache_wsupdate_all, reinterpret_cast<void*>(10)) != 0) + &(g_cache_list.m_update_thread), nullptr, rtl_cache_wsupdate_all, reinterpret_cast<void*>(10)) != 0) { /* failure */ g_cache_list.m_update_thread = pthread_t(); @@ -1351,7 +1351,7 @@ rtl_cache_wsupdate_wait (unsigned int seconds) timeval now; timespec wakeup; - gettimeofday(&now, 0); + gettimeofday(&now, nullptr); wakeup.tv_sec = now.tv_sec + (seconds); wakeup.tv_nsec = now.tv_usec * 1000; @@ -1371,7 +1371,7 @@ rtl_cache_wsupdate_fini() RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); if (g_cache_list.m_update_thread != pthread_t()) - pthread_join (g_cache_list.m_update_thread, NULL); + pthread_join (g_cache_list.m_update_thread, nullptr); } /* ================================================================= */ @@ -1447,7 +1447,7 @@ rtl_cache_depot_wsupdate ( for (; npurge > 0; npurge--) { rtl_cache_magazine_type * mag = rtl_cache_depot_dequeue (depot); - if (mag != 0) + if (mag != nullptr) { RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); rtl_cache_magazine_clear (cache, mag); @@ -1467,7 +1467,7 @@ rtl_cache_wsupdate ( rtl_cache_type * cache ) { - if (cache->m_magazine_cache != 0) + if (cache->m_magazine_cache != nullptr) { RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); @@ -1522,7 +1522,7 @@ rtl_cache_wsupdate_all (void * arg) } RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - return 0; + return nullptr; } /* ================================================================= * @@ -1541,27 +1541,27 @@ rtl_cache_init() } { /* cache: internal arena */ - assert(gp_cache_arena == 0); + assert(gp_cache_arena == nullptr); gp_cache_arena = rtl_arena_create ( "rtl_cache_internal_arena", 64, /* quantum */ 0, /* no quantum caching */ - NULL, /* default source */ + nullptr, /* default source */ rtl_arena_alloc, rtl_arena_free, 0 /* flags */ ); - assert(gp_cache_arena != 0); + assert(gp_cache_arena != nullptr); /* check 'gp_default_arena' initialization */ - assert(gp_default_arena != 0); + assert(gp_default_arena != nullptr); } { /* cache: magazine cache */ static rtl_cache_type g_cache_magazine_cache; - assert(gp_cache_magazine_cache == 0); + assert(gp_cache_magazine_cache == nullptr); (void) rtl_cache_constructor (&g_cache_magazine_cache); gp_cache_magazine_cache = rtl_cache_activate ( @@ -1571,12 +1571,12 @@ rtl_cache_init() 0, /* objalign */ rtl_cache_magazine_constructor, rtl_cache_magazine_destructor, - 0, /* reclaim */ - 0, /* userarg: NYI */ + nullptr, /* reclaim */ + nullptr, /* userarg: NYI */ gp_default_arena, /* source */ RTL_CACHE_FLAG_NOMAGAZINE /* during bootstrap; activated below */ ); - assert(gp_cache_magazine_cache != 0); + assert(gp_cache_magazine_cache != nullptr); /* activate magazine layer */ g_cache_magazine_cache.m_magazine_cache = gp_cache_magazine_cache; @@ -1585,7 +1585,7 @@ rtl_cache_init() /* cache: slab (struct) cache */ static rtl_cache_type g_cache_slab_cache; - assert(gp_cache_slab_cache == 0); + assert(gp_cache_slab_cache == nullptr); (void) rtl_cache_constructor (&g_cache_slab_cache); gp_cache_slab_cache = rtl_cache_activate ( @@ -1595,18 +1595,18 @@ rtl_cache_init() 0, /* objalign */ rtl_cache_slab_constructor, rtl_cache_slab_destructor, - 0, /* reclaim */ - 0, /* userarg: none */ + nullptr, /* reclaim */ + nullptr, /* userarg: none */ gp_default_arena, /* source */ 0 /* flags: none */ ); - assert(gp_cache_slab_cache != 0); + assert(gp_cache_slab_cache != nullptr); } { /* cache: bufctl cache */ static rtl_cache_type g_cache_bufctl_cache; - assert(gp_cache_bufctl_cache == 0); + assert(gp_cache_bufctl_cache == nullptr); (void) rtl_cache_constructor (&g_cache_bufctl_cache); gp_cache_bufctl_cache = rtl_cache_activate ( @@ -1614,14 +1614,14 @@ rtl_cache_init() "rtl_cache_bufctl_cache", sizeof(rtl_cache_bufctl_type), /* objsize */ 0, /* objalign */ - 0, /* constructor */ - 0, /* destructor */ - 0, /* reclaim */ - 0, /* userarg */ + nullptr, /* constructor */ + nullptr, /* destructor */ + nullptr, /* reclaim */ + nullptr, /* userarg */ gp_default_arena, /* source */ 0 /* flags: none */ ); - assert(gp_cache_bufctl_cache != 0); + assert(gp_cache_bufctl_cache != nullptr); } rtl_cache_wsupdate_init(); @@ -1633,34 +1633,34 @@ rtl_cache_init() void rtl_cache_fini() { - if (gp_cache_arena != 0) + if (gp_cache_arena != nullptr) { rtl_cache_type * cache, * head; rtl_cache_wsupdate_fini(); - if (gp_cache_bufctl_cache != 0) + if (gp_cache_bufctl_cache != nullptr) { - cache = gp_cache_bufctl_cache, gp_cache_bufctl_cache = 0; + cache = gp_cache_bufctl_cache, gp_cache_bufctl_cache = nullptr; rtl_cache_deactivate (cache); rtl_cache_destructor (cache); } - if (gp_cache_slab_cache != 0) + if (gp_cache_slab_cache != nullptr) { - cache = gp_cache_slab_cache, gp_cache_slab_cache = 0; + cache = gp_cache_slab_cache, gp_cache_slab_cache = nullptr; rtl_cache_deactivate (cache); rtl_cache_destructor (cache); } - if (gp_cache_magazine_cache != 0) + if (gp_cache_magazine_cache != nullptr) { - cache = gp_cache_magazine_cache, gp_cache_magazine_cache = 0; + cache = gp_cache_magazine_cache, gp_cache_magazine_cache = nullptr; rtl_cache_deactivate (cache); rtl_cache_destructor (cache); } - if (gp_cache_arena != 0) + if (gp_cache_arena != nullptr) { rtl_arena_destroy (gp_cache_arena); - gp_cache_arena = 0; + gp_cache_arena = nullptr; } RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); diff --git a/sal/rtl/alloc_global.cxx b/sal/rtl/alloc_global.cxx index 60dbc9c85b78..ca6601bfd213 100644 --- a/sal/rtl/alloc_global.cxx +++ b/sal/rtl/alloc_global.cxx @@ -35,7 +35,7 @@ AllocMode alloc_mode = AMode_UNSET; static void determine_alloc_mode() { assert(alloc_mode == AMode_UNSET); - alloc_mode = (getenv("G_SLICE") == NULL ? AMode_CUSTOM : AMode_SYSTEM); + alloc_mode = (getenv("G_SLICE") == nullptr ? AMode_CUSTOM : AMode_SYSTEM); } /* ================================================================= * @@ -73,7 +73,7 @@ static const sal_Size g_alloc_sizes[] = static rtl_cache_type * g_alloc_caches[RTL_MEMORY_CACHED_SIZES] = { - 0, + nullptr, }; #define RTL_MEMALIGN 8 @@ -81,10 +81,10 @@ static rtl_cache_type * g_alloc_caches[RTL_MEMORY_CACHED_SIZES] = static rtl_cache_type * g_alloc_table[RTL_MEMORY_CACHED_LIMIT >> RTL_MEMALIGN_SHIFT] = { - 0, + nullptr, }; -static rtl_arena_type * gp_alloc_arena = 0; +static rtl_arena_type * gp_alloc_arena = nullptr; /* ================================================================= * * @@ -95,7 +95,7 @@ static rtl_arena_type * gp_alloc_arena = 0; void * SAL_CALL rtl_allocateMemory_CUSTOM (sal_Size n) SAL_THROW_EXTERN_C() { - void * p = 0; + void * p = nullptr; if (n > 0) { char * addr; @@ -105,7 +105,7 @@ SAL_CALL rtl_allocateMemory_CUSTOM (sal_Size n) SAL_THROW_EXTERN_C() if (n >= SAL_MAX_SIZE - (RTL_MEMALIGN + RTL_MEMALIGN - 1)) { /* requested size too large for roundup alignment */ - return 0; + return nullptr; } try_alloc: @@ -114,12 +114,12 @@ try_alloc: else addr = static_cast<char*>(rtl_arena_alloc (gp_alloc_arena, &size)); - if (addr != 0) + if (addr != nullptr) { reinterpret_cast<sal_Size*>(addr)[0] = size; p = addr + RTL_MEMALIGN; } - else if (gp_alloc_arena == 0) + else if (gp_alloc_arena == nullptr) { ensureMemorySingleton(); if (gp_alloc_arena) @@ -136,7 +136,7 @@ try_alloc: void SAL_CALL rtl_freeMemory_CUSTOM (void * p) SAL_THROW_EXTERN_C() { - if (p != 0) + if (p != nullptr) { char * addr = static_cast<char*>(p) - RTL_MEMALIGN; sal_Size size = reinterpret_cast<sal_Size*>(addr)[0]; @@ -154,13 +154,13 @@ void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXT { if (n > 0) { - if (p != 0) + if (p != nullptr) { void * p_old = p; sal_Size n_old = reinterpret_cast<sal_Size*>( static_cast<char*>(p) - RTL_MEMALIGN )[0] - RTL_MEMALIGN; p = rtl_allocateMemory (n); - if (p != 0) + if (p != nullptr) { memcpy (p, p_old, (n < n_old) ? n : n_old); rtl_freeMemory (p_old); @@ -171,9 +171,9 @@ void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXT p = rtl_allocateMemory (n); } } - else if (p != 0) + else if (p != nullptr) { - rtl_freeMemory (p), p = 0; + rtl_freeMemory (p), p = nullptr; } return p; } @@ -191,18 +191,18 @@ void rtl_memory_init() #if !defined(FORCE_SYSALLOC) { /* global memory arena */ - assert(gp_alloc_arena == 0); + assert(gp_alloc_arena == nullptr); gp_alloc_arena = rtl_arena_create ( "rtl_alloc_arena", 2048, /* quantum */ 0, /* w/o quantum caching */ - 0, /* default source */ + nullptr, /* default source */ rtl_arena_alloc, rtl_arena_free, 0 /* flags */ ); - assert(gp_alloc_arena != 0); + assert(gp_alloc_arena != nullptr); } { sal_Size size; @@ -212,7 +212,7 @@ void rtl_memory_init() { char name[RTL_CACHE_NAME_LENGTH + 1]; (void) snprintf (name, sizeof(name), "rtl_alloc_%" SAL_PRIuUINTPTR, g_alloc_sizes[i]); - g_alloc_caches[i] = rtl_cache_create (name, g_alloc_sizes[i], 0, NULL, NULL, NULL, NULL, NULL, 0); + g_alloc_caches[i] = rtl_cache_create (name, g_alloc_sizes[i], 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0); } size = RTL_MEMALIGN; @@ -242,18 +242,18 @@ void rtl_memory_fini() /* cleanup g_alloc_caches */ for (i = 0, n = RTL_MEMORY_CACHED_SIZES; i < n; i++) { - if (g_alloc_caches[i] != 0) + if (g_alloc_caches[i] != nullptr) { rtl_cache_destroy (g_alloc_caches[i]); - g_alloc_caches[i] = 0; + g_alloc_caches[i] = nullptr; } } /* cleanup gp_alloc_arena */ - if (gp_alloc_arena != 0) + if (gp_alloc_arena != nullptr) { rtl_arena_destroy (gp_alloc_arena); - gp_alloc_arena = 0; + gp_alloc_arena = nullptr; } #endif // SAL_INFO("sal.rtl", "rtl_memory_fini completed"); @@ -363,7 +363,7 @@ void SAL_CALL rtl_freeMemory (void * p) SAL_THROW_EXTERN_C() void * SAL_CALL rtl_allocateZeroMemory (sal_Size n) SAL_THROW_EXTERN_C() { void * p = rtl_allocateMemory (n); - if (p != 0) + if (p != nullptr) memset (p, 0, n); return p; } @@ -372,7 +372,7 @@ void * SAL_CALL rtl_allocateZeroMemory (sal_Size n) SAL_THROW_EXTERN_C() void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C() { - if (p != 0) + if (p != nullptr) { rtl_secureZeroMemory (p, n); rtl_freeMemory (p); diff --git a/sal/rtl/alloc_impl.hxx b/sal/rtl/alloc_impl.hxx index 05ec242889a7..61c0e88100e5 100644 --- a/sal/rtl/alloc_impl.hxx +++ b/sal/rtl/alloc_impl.hxx @@ -163,7 +163,7 @@ lowbit(sal_Size n) typedef pthread_mutex_t rtl_memory_lock_type; -#define RTL_MEMORY_LOCK_INIT(lock) pthread_mutex_init((lock), NULL) +#define RTL_MEMORY_LOCK_INIT(lock) pthread_mutex_init((lock), nullptr) #define RTL_MEMORY_LOCK_DESTROY(lock) pthread_mutex_destroy((lock)) #define RTL_MEMORY_LOCK_ACQUIRE(lock) pthread_mutex_lock((lock)) diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index e41b89aae062..bd1e948f8c92 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -74,7 +74,7 @@ bool isPathnameUrl(rtl::OUString const & url) { } bool resolvePathnameUrl(rtl::OUString * url) { - OSL_ASSERT(url != NULL); + OSL_ASSERT(url != nullptr); if (!isPathnameUrl(*url) || (osl::FileBase::getFileURLFromSystemPath( url->copy(RTL_CONSTASCII_LENGTH(VND_SUN_STAR_PATHNAME)), *url) == @@ -106,7 +106,7 @@ rtl::OUString recursivelyExpandMacros( Bootstrap_Impl const * requestFile, rtl::OUString const & requestKey, ExpandRequestLink const * requestStack) { - for (; requestStack != NULL; requestStack = requestStack->next) { + for (; requestStack != nullptr; requestStack = requestStack->next) { if (requestStack->file == requestFile && requestStack->key == requestKey) { @@ -139,7 +139,7 @@ bool find( NameValueList const & list, rtl::OUString const & key, rtl::OUString * value) { - OSL_ASSERT(value != NULL); + OSL_ASSERT(value != nullptr); for (NameValueList::const_iterator i(list.begin()); i != list.end(); ++i) { if (i->sName == key) { *value = i->sValue; @@ -157,8 +157,8 @@ namespace { static bool getFromCommandLineArgs( rtl::OUString const & key, rtl::OUString * value ) { - OSL_ASSERT(value != NULL); - static NameValueList *pNameValueList = 0; + OSL_ASSERT(value != nullptr); + static NameValueList *pNameValueList = nullptr; if( ! pNameValueList ) { static NameValueList nameValueList; @@ -166,7 +166,7 @@ static bool getFromCommandLineArgs( sal_Int32 nArgCount = osl_getCommandArgCount(); for(sal_Int32 i = 0; i < nArgCount; ++ i) { - rtl_uString *pArg = 0; + rtl_uString *pArg = nullptr; osl_getCommandArg( i, &pArg ); if( ('-' == pArg->buffer[0] || '/' == pArg->buffer[0] ) && 'e' == pArg->buffer[1] && @@ -229,7 +229,7 @@ static void getExecutableDirectory_Impl (rtl_uString ** ppDirURL) static OUString & getIniFileName_Impl() { osl::MutexGuard guard( osl::Mutex::getGlobalMutex() ); - static OUString *pStaticName = 0; + static OUString *pStaticName = nullptr; if( ! pStaticName ) { OUString fileName; @@ -335,7 +335,7 @@ struct Bootstrap_Impl Bootstrap_Impl::Bootstrap_Impl( OUString const & rIniName ) : _nRefCount( 0 ), - _base_ini( 0 ), + _base_ini( nullptr ), _iniName (rIniName) { OUString base_ini( getIniFileName_Impl() ); @@ -400,7 +400,7 @@ Bootstrap_Impl::Bootstrap_Impl( OUString const & rIniName ) Bootstrap_Impl::~Bootstrap_Impl() { - if (_base_ini != 0) + if (_base_ini != nullptr) rtl_bootstrap_args_close( _base_ini ); } @@ -409,13 +409,13 @@ namespace { Bootstrap_Impl * get_static_bootstrap_handle() { osl::MutexGuard guard( osl::Mutex::getGlobalMutex() ); - static Bootstrap_Impl * s_handle = 0; - if (s_handle == 0) + static Bootstrap_Impl * s_handle = nullptr; + if (s_handle == nullptr) { OUString iniName (getIniFileName_Impl()); s_handle = static_cast< Bootstrap_Impl * >( rtl_bootstrap_args_open( iniName.pData ) ); - if (s_handle == 0) + if (s_handle == nullptr) { Bootstrap_Impl * that = new Bootstrap_Impl( iniName ); ++that->_nRefCount; @@ -434,9 +434,9 @@ struct FundamentalIniData: private boost::noncopyable { ((static_cast< Bootstrap_Impl * >(get_static_bootstrap_handle())-> getValue( "URE_BOOTSTRAP", - &uri.pData, 0, LOOKUP_MODE_NORMAL, false, 0)) && + &uri.pData, nullptr, LOOKUP_MODE_NORMAL, false, nullptr)) && resolvePathnameUrl(&uri)) - ? rtl_bootstrap_args_open(uri.pData) : NULL; + ? rtl_bootstrap_args_open(uri.pData) : nullptr; } ~FundamentalIniData() { rtl_bootstrap_args_close(ini); } @@ -520,7 +520,7 @@ bool Bootstrap_Impl::getValue( getExecutableDirectory_Impl(value); return true; } - if (_base_ini != NULL && + if (_base_ini != nullptr && _base_ini->getDirectValue(key, value, mode, requestStack)) { return true; @@ -531,13 +531,13 @@ bool Bootstrap_Impl::getValue( if (mode == LOOKUP_MODE_NORMAL) { FundamentalIniData const & d = FundamentalIni::get(); Bootstrap_Impl const * b = static_cast<Bootstrap_Impl const *>(d.ini); - if (b != NULL && b != this && + if (b != nullptr && b != this && b->getDirectValue(key, value, mode, requestStack)) { return true; } } - if (defaultValue != NULL) { + if (defaultValue != nullptr) { rtl_uString_assign(value, defaultValue); return true; } @@ -571,7 +571,7 @@ bool Bootstrap_Impl::getAmbienceValue( if (f || getFromCommandLineArgs(key, &v) || osl_getEnvironment(key.pData, &v.pData) == osl_Process_E_None) { - expandValue(value, v, mode, NULL, key, requestStack); + expandValue(value, v, mode, nullptr, key, requestStack); return true; } else { return false; @@ -605,16 +605,16 @@ struct bootstrap_map: private boost::noncopyable { // (e.g., osl::Mutex::getGlobalMutex()): static t * get() { - if (m_map == NULL) { + if (m_map == nullptr) { m_map = new t; } return m_map; } static void release() { - if (m_map != NULL && m_map->empty()) { + if (m_map != nullptr && m_map->empty()) { delete m_map; - m_map = NULL; + m_map = nullptr; } } @@ -622,7 +622,7 @@ private: static t * m_map; }; -bootstrap_map::t * bootstrap_map::m_map = NULL; +bootstrap_map::t * bootstrap_map::m_map = nullptr; } @@ -638,7 +638,7 @@ rtlBootstrapHandle SAL_CALL rtl_bootstrap_args_open ( if (DirectoryItem::E_None != DirectoryItem::get( iniName, dirItem ) || DirectoryItem::E_None != dirItem.getFileStatus( status )) { - return 0; + return nullptr; } iniName = status.getFileURL(); @@ -684,7 +684,7 @@ void SAL_CALL rtl_bootstrap_args_close ( rtlBootstrapHandle handle ) SAL_THROW_EXTERN_C() { - if (handle == 0) + if (handle == nullptr) return; Bootstrap_Impl * that = static_cast< Bootstrap_Impl * >( handle ); @@ -727,10 +727,10 @@ sal_Bool SAL_CALL rtl_bootstrap_get_from_handle( bool found = false; if(ppValue && pName) { - if (handle == 0) + if (handle == nullptr) handle = get_static_bootstrap_handle(); found = static_cast< Bootstrap_Impl * >( handle )->getValue( - pName, ppValue, pDefault, LOOKUP_MODE_NORMAL, false, NULL ); + pName, ppValue, pDefault, LOOKUP_MODE_NORMAL, false, nullptr ); } return found; @@ -771,7 +771,7 @@ sal_Bool SAL_CALL rtl_bootstrap_get ( rtl_uString * pDefault ) { - return rtl_bootstrap_get_from_handle(0, pName, ppValue, pDefault); + return rtl_bootstrap_get_from_handle(nullptr, pName, ppValue, pDefault); } void SAL_CALL rtl_bootstrap_set ( @@ -811,23 +811,23 @@ void SAL_CALL rtl_bootstrap_expandMacros_from_handle( rtlBootstrapHandle handle, rtl_uString ** macro) { - if (handle == NULL) { + if (handle == nullptr) { handle = get_static_bootstrap_handle(); } OUString expanded( expandMacros( static_cast< Bootstrap_Impl * >( handle ), OUString::unacquired( macro ), - LOOKUP_MODE_NORMAL, NULL ) ); + LOOKUP_MODE_NORMAL, nullptr ) ); rtl_uString_assign( macro, expanded.pData ); } void SAL_CALL rtl_bootstrap_expandMacros(rtl_uString ** macro) { - rtl_bootstrap_expandMacros_from_handle(NULL, macro); + rtl_bootstrap_expandMacros_from_handle(nullptr, macro); } void rtl_bootstrap_encode( rtl_uString const * value, rtl_uString ** encoded ) { - OSL_ASSERT(value != NULL); + OSL_ASSERT(value != nullptr); rtl::OUStringBuffer b; for (sal_Int32 i = 0; i < value->length; ++i) { sal_Unicode c = value->buffer[i]; @@ -850,7 +850,7 @@ int hex(sal_Unicode c) { sal_Unicode read(rtl::OUString const & text, sal_Int32 * pos, bool * escaped) { OSL_ASSERT( - pos != NULL && *pos >= 0 && *pos < text.getLength() && escaped != NULL); + pos != nullptr && *pos >= 0 && *pos < text.getLength() && escaped != nullptr); sal_Unicode c = text[(*pos)++]; if (c == '\\') { int n1, n2, n3, n4; @@ -878,8 +878,8 @@ rtl::OUString lookup( rtl::OUString const & key, ExpandRequestLink const * requestStack) { rtl::OUString v; - (file == NULL ? get_static_bootstrap_handle() : file)->getValue( - key, &v.pData, NULL, mode, override, requestStack); + (file == nullptr ? get_static_bootstrap_handle() : file)->getValue( + key, &v.pData, nullptr, mode, override, requestStack); return v; } @@ -937,7 +937,7 @@ rtl::OUString expandMacros( Bootstrap_Impl * f = static_cast< Bootstrap_Impl * >( b.getHandle()); buf.append( - lookup(f, mode, f != NULL, seg[2], requestStack)); + lookup(f, mode, f != nullptr, seg[2], requestStack)); } else { if (n == 3 && seg[1].isEmpty()) { // For backward compatibility, treat ${file::key} the diff --git a/sal/rtl/byteseq.cxx b/sal/rtl/byteseq.cxx index 024719adaff0..891c492f2db2 100644 --- a/sal/rtl/byteseq.cxx +++ b/sal/rtl/byteseq.cxx @@ -52,7 +52,7 @@ void SAL_CALL rtl_byte_sequence_reference2One( { pNew = static_cast<sal_Sequence *>(rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nElements )); - if ( pNew != 0 ) + if ( pNew != nullptr ) memcpy( pNew->elements, pSequence->elements, nElements ); if (! osl_atomic_decrement( &pSequence->nRefCount )) @@ -63,7 +63,7 @@ void SAL_CALL rtl_byte_sequence_reference2One( pNew = static_cast<sal_Sequence *>(rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE )); } - if ( pNew != 0 ) + if ( pNew != nullptr ) { pNew->nRefCount = 1; pNew->nElements = nElements; @@ -90,7 +90,7 @@ void SAL_CALL rtl_byte_sequence_realloc( { pNew = static_cast<sal_Sequence *>(rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nSize )); - if ( pNew != 0 ) + if ( pNew != nullptr ) { if (nSize > nElements) { @@ -113,7 +113,7 @@ void SAL_CALL rtl_byte_sequence_realloc( pSequence, SAL_SEQUENCE_HEADER_SIZE + nSize )); } - if ( pSequence != 0 ) + if ( pSequence != nullptr ) { pSequence->nRefCount = 1; pSequence->nElements = nSize; @@ -132,7 +132,7 @@ void SAL_CALL rtl_byte_sequence_acquire( sal_Sequence *pSequence ) void SAL_CALL rtl_byte_sequence_release( sal_Sequence *pSequence ) SAL_THROW_EXTERN_C() { - if ( pSequence != 0 ) + if ( pSequence != nullptr ) { if (! osl_atomic_decrement( &(pSequence->nRefCount )) ) { @@ -148,14 +148,14 @@ void SAL_CALL rtl_byte_sequence_construct( sal_Sequence **ppSequence , sal_Int32 if( *ppSequence ) { rtl_byte_sequence_release( *ppSequence ); - *ppSequence = 0; + *ppSequence = nullptr; } if( nLength ) { *ppSequence = static_cast<sal_Sequence *>(rtl_allocateZeroMemory( SAL_SEQUENCE_HEADER_SIZE + nLength )); - if ( *ppSequence != 0 ) + if ( *ppSequence != nullptr ) { (*ppSequence)->nRefCount = 1; (*ppSequence)->nElements = nLength; @@ -175,12 +175,12 @@ void SAL_CALL rtl_byte_sequence_constructNoDefault( sal_Sequence **ppSequence , if( *ppSequence ) { rtl_byte_sequence_release( *ppSequence ); - *ppSequence = 0; + *ppSequence = nullptr; } *ppSequence = static_cast<sal_Sequence *>(rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nLength )); - if ( *ppSequence != 0 ) + if ( *ppSequence != nullptr ) { (*ppSequence)->nRefCount = 1; (*ppSequence)->nElements = nLength; @@ -192,7 +192,7 @@ void SAL_CALL rtl_byte_sequence_constructFromArray( SAL_THROW_EXTERN_C() { rtl_byte_sequence_constructNoDefault( ppSequence , nLength ); - if ( *ppSequence != 0 && nLength != 0 ) + if ( *ppSequence != nullptr && nLength != 0 ) memcpy( (*ppSequence)->elements, pData, nLength ); } diff --git a/sal/rtl/cipher.cxx b/sal/rtl/cipher.cxx index c5bd0f24d834..0bcaa49f5038 100644 --- a/sal/rtl/cipher.cxx +++ b/sal/rtl/cipher.cxx @@ -139,9 +139,9 @@ rtlCipherError SAL_CALL rtl_cipher_init ( const sal_uInt8 *pArgData, sal_Size nArgLen) SAL_THROW_EXTERN_C() { Cipher_Impl *pImpl = static_cast<Cipher_Impl*>(Cipher); - if (pImpl == NULL) + if (pImpl == nullptr) return rtl_Cipher_E_Argument; - if (pImpl->m_init == NULL) + if (pImpl->m_init == nullptr) return rtl_Cipher_E_Unknown; return (pImpl->m_init)( @@ -157,9 +157,9 @@ rtlCipherError SAL_CALL rtl_cipher_encode ( sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() { Cipher_Impl *pImpl = static_cast<Cipher_Impl*>(Cipher); - if (pImpl == NULL) + if (pImpl == nullptr) return rtl_Cipher_E_Argument; - if (pImpl->m_encode == NULL) + if (pImpl->m_encode == nullptr) return rtl_Cipher_E_Unknown; return (pImpl->m_encode)(Cipher, pData, nDatLen, pBuffer, nBufLen); @@ -174,9 +174,9 @@ rtlCipherError SAL_CALL rtl_cipher_decode ( sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() { Cipher_Impl *pImpl = static_cast<Cipher_Impl*>(Cipher); - if (pImpl == NULL) + if (pImpl == nullptr) return rtl_Cipher_E_Argument; - if (pImpl->m_decode == NULL) + if (pImpl->m_decode == nullptr) return rtl_Cipher_E_Unknown; return (pImpl->m_decode)(Cipher, pData, nDatLen, pBuffer, nBufLen); @@ -726,7 +726,7 @@ static rtlCipherError __rtl_cipherBF_update ( sal_uInt8 *pBuffer, sal_Size nBufLen) { /* Check arguments. */ - if ((pData == NULL) || (pBuffer == NULL)) + if ((pData == nullptr) || (pBuffer == nullptr)) return rtl_Cipher_E_Argument; if (!((0 < nDatLen) && (nDatLen <= nBufLen))) @@ -897,7 +897,7 @@ static void __rtl_cipherBF_updateCFB ( } ctx->m_offset = ((k + 1) & 0x07); - iv = NULL; + iv = nullptr; } /* @@ -1036,7 +1036,7 @@ rtlCipherError SAL_CALL rtl_cipher_initBF ( { CipherBF_Impl *pImpl = static_cast<CipherBF_Impl*>(Cipher); - if ((pImpl == NULL) || (pKeyData == NULL)) + if ((pImpl == nullptr) || (pKeyData == nullptr)) return rtl_Cipher_E_Argument; if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) @@ -1061,7 +1061,7 @@ rtlCipherError SAL_CALL rtl_cipher_encodeBF ( sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() { CipherBF_Impl *pImpl = static_cast<CipherBF_Impl*>(Cipher); - if (pImpl == NULL) + if (pImpl == nullptr) return rtl_Cipher_E_Argument; if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) @@ -1087,7 +1087,7 @@ rtlCipherError SAL_CALL rtl_cipher_decodeBF ( sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() { CipherBF_Impl *pImpl = static_cast<CipherBF_Impl*>(Cipher); - if (pImpl == NULL) + if (pImpl == nullptr) return rtl_Cipher_E_Argument; if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF)) @@ -1198,7 +1198,7 @@ static rtlCipherError rtl_cipherARCFOUR_update_Impl ( sal_Size k; /* Check arguments. */ - if ((pData == NULL) || (pBuffer == NULL)) + if ((pData == nullptr) || (pBuffer == nullptr)) return rtl_Cipher_E_Argument; if (!((0 < nDatLen) && (nDatLen <= nBufLen))) @@ -1273,7 +1273,7 @@ rtlCipherError SAL_CALL rtl_cipher_initARCFOUR ( { CipherARCFOUR_Impl *pImpl = static_cast<CipherARCFOUR_Impl*>(Cipher); - if ((pImpl == NULL) || (pKeyData == NULL)) + if ((pImpl == nullptr) || (pKeyData == nullptr)) return rtl_Cipher_E_Argument; if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) @@ -1296,7 +1296,7 @@ rtlCipherError SAL_CALL rtl_cipher_encodeARCFOUR ( sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() { CipherARCFOUR_Impl *pImpl = static_cast<CipherARCFOUR_Impl*>(Cipher); - if (pImpl == NULL) + if (pImpl == nullptr) return rtl_Cipher_E_Argument; if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) @@ -1319,7 +1319,7 @@ rtlCipherError SAL_CALL rtl_cipher_decodeARCFOUR ( sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C() { CipherARCFOUR_Impl *pImpl = static_cast<CipherARCFOUR_Impl*>(Cipher); - if (pImpl == NULL) + if (pImpl == nullptr) return rtl_Cipher_E_Argument; if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR)) diff --git a/sal/rtl/cmdargs.cxx b/sal/rtl/cmdargs.cxx index 0baae609efdf..ee4bead37c10 100644 --- a/sal/rtl/cmdargs.cxx +++ b/sal/rtl/cmdargs.cxx @@ -23,7 +23,7 @@ namespace { -rtl_uString ** g_ppCommandArgs = 0; +rtl_uString ** g_ppCommandArgs = nullptr; sal_uInt32 g_nCommandArgCount = 0; struct ArgHolder @@ -37,7 +37,7 @@ ArgHolder::~ArgHolder() rtl_uString_release (g_ppCommandArgs[--g_nCommandArgCount]); rtl_freeMemory (g_ppCommandArgs); - g_ppCommandArgs = 0; + g_ppCommandArgs = nullptr; } // The destructor of this static ArgHolder is "activated" by the assignments to @@ -55,7 +55,7 @@ void init() static_cast<rtl_uString**>(rtl_allocateZeroMemory (n * sizeof(rtl_uString*))); for (i = 0; i < n; i++) { - rtl_uString * pArg = 0; + rtl_uString * pArg = nullptr; osl_getCommandArg (i, &pArg); if (('-' == pArg->buffer[0] || '/' == pArg->buffer[0]) && 'e' == pArg->buffer[1] && diff --git a/sal/rtl/digest.cxx b/sal/rtl/digest.cxx index b997dcfc9357..da6df0ef2e32 100644 --- a/sal/rtl/digest.cxx +++ b/sal/rtl/digest.cxx @@ -278,7 +278,7 @@ static const Digest_Impl __rtl_digest_MD2 = rtl_Digest_AlgorithmMD2, RTL_DIGEST_LENGTH_MD2, - NULL, + nullptr, rtl_digest_destroyMD2, rtl_digest_updateMD2, rtl_digest_getMD2 @@ -412,7 +412,7 @@ rtlDigestError SAL_CALL rtl_digest_updateMD2 ( DigestContextMD2 *ctx; - if ((pImpl == NULL) || (pData == NULL)) + if ((pImpl == nullptr) || (pData == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2)) @@ -471,7 +471,7 @@ rtlDigestError SAL_CALL rtl_digest_getMD2 ( DigestContextMD2 *ctx; - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2)) @@ -564,7 +564,7 @@ static const Digest_Impl __rtl_digest_MD5 = rtl_Digest_AlgorithmMD5, RTL_DIGEST_LENGTH_MD5, - NULL, + nullptr, rtl_digest_destroyMD5, rtl_digest_updateMD5, rtl_digest_getMD5 @@ -784,7 +784,7 @@ rtlDigestError SAL_CALL rtl_digest_updateMD5 ( DigestContextMD5 *ctx; sal_uInt32 len; - if ((pImpl == NULL) || (pData == NULL)) + if ((pImpl == nullptr) || (pData == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) @@ -856,7 +856,7 @@ rtlDigestError SAL_CALL rtl_digest_getMD5 ( DigestContextMD5 *ctx; - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) @@ -889,7 +889,7 @@ rtlDigestError SAL_CALL rtl_digest_rawMD5 ( DigestContextMD5 *ctx; - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5)) @@ -1200,7 +1200,7 @@ static const Digest_Impl __rtl_digest_SHA_0 = rtl_Digest_AlgorithmSHA, RTL_DIGEST_LENGTH_SHA, - NULL, + nullptr, rtl_digest_destroySHA, rtl_digest_updateSHA, rtl_digest_getSHA @@ -1268,7 +1268,7 @@ rtlDigestError SAL_CALL rtl_digest_updateSHA ( DigestContextSHA *ctx; sal_uInt32 len; - if ((pImpl == NULL) || (pData == NULL)) + if ((pImpl == nullptr) || (pData == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA)) @@ -1340,7 +1340,7 @@ rtlDigestError SAL_CALL rtl_digest_getSHA ( DigestContextSHA *ctx; - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA)) @@ -1390,7 +1390,7 @@ static const Digest_Impl __rtl_digest_SHA_1 = rtl_Digest_AlgorithmSHA1, RTL_DIGEST_LENGTH_SHA1, - NULL, + nullptr, rtl_digest_destroySHA1, rtl_digest_updateSHA1, rtl_digest_getSHA1 @@ -1458,7 +1458,7 @@ rtlDigestError SAL_CALL rtl_digest_updateSHA1 ( DigestContextSHA *ctx; sal_uInt32 len; - if ((pImpl == NULL) || (pData == NULL)) + if ((pImpl == nullptr) || (pData == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA1)) @@ -1530,7 +1530,7 @@ rtlDigestError SAL_CALL rtl_digest_getSHA1 ( DigestContextSHA *ctx; - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmSHA1)) @@ -1698,7 +1698,7 @@ rtlDigestError SAL_CALL rtl_digest_initHMAC_MD5 ( DigestHMAC_MD5_Impl *pImpl = static_cast<DigestHMAC_MD5_Impl*>(Digest); ContextHMAC_MD5 *ctx; - if ((pImpl == NULL) || (pKeyData == NULL)) + if ((pImpl == nullptr) || (pKeyData == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) @@ -1737,7 +1737,7 @@ rtlDigestError SAL_CALL rtl_digest_updateHMAC_MD5 ( DigestHMAC_MD5_Impl *pImpl = static_cast<DigestHMAC_MD5_Impl*>(Digest); ContextHMAC_MD5 *ctx; - if ((pImpl == NULL) || (pData == NULL)) + if ((pImpl == nullptr) || (pData == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) @@ -1759,7 +1759,7 @@ rtlDigestError SAL_CALL rtl_digest_getHMAC_MD5 ( DigestHMAC_MD5_Impl *pImpl = static_cast<DigestHMAC_MD5_Impl*>(Digest); ContextHMAC_MD5 *ctx; - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_MD5)) @@ -1930,7 +1930,7 @@ rtlDigestError SAL_CALL rtl_digest_initHMAC_SHA1 ( DigestHMAC_SHA1_Impl *pImpl = static_cast<DigestHMAC_SHA1_Impl*>(Digest); ContextHMAC_SHA1 *ctx; - if ((pImpl == NULL) || (pKeyData == NULL)) + if ((pImpl == nullptr) || (pKeyData == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) @@ -1969,7 +1969,7 @@ rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 ( DigestHMAC_SHA1_Impl *pImpl = static_cast<DigestHMAC_SHA1_Impl*>(Digest); ContextHMAC_SHA1 *ctx; - if ((pImpl == NULL) || (pData == NULL)) + if ((pImpl == nullptr) || (pData == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) @@ -1991,7 +1991,7 @@ rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 ( DigestHMAC_SHA1_Impl *pImpl = static_cast<DigestHMAC_SHA1_Impl*>(Digest); ContextHMAC_SHA1 *ctx; - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Digest_E_Argument; if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmHMAC_SHA1)) @@ -2091,7 +2091,7 @@ rtlDigestError SAL_CALL rtl_digest_PBKDF2 ( DigestHMAC_SHA1_Impl digest; sal_uInt32 i = 1; - if ((pKeyData == NULL) || (pPassData == NULL) || (pSaltData == NULL)) + if ((pKeyData == nullptr) || (pPassData == nullptr) || (pSaltData == nullptr)) return rtl_Digest_E_Argument; digest.m_digest = __rtl_digest_HMAC_SHA1; diff --git a/sal/rtl/hash.cxx b/sal/rtl/hash.cxx index 03ae02dcc4ee..9df367f25f7d 100644 --- a/sal/rtl/hash.cxx +++ b/sal/rtl/hash.cxx @@ -37,8 +37,8 @@ static void rtl_str_hash_free (StringHashTable *pHash); StringHashTable * getHashTable () { - static StringHashTable *pInternPool = NULL; - if (pInternPool == NULL) { + static StringHashTable *pInternPool = nullptr; + if (pInternPool == nullptr) { static StringHashTable* pHash = rtl_str_hash_new(1024); pInternPool = pHash; } @@ -103,7 +103,7 @@ rtl_str_hash_insert_nonequal (StringHashTable *pHash, sal_uInt32 n; n = nHash % pHash->nSize; - while (pHash->pData[n] != NULL) { + while (pHash->pData[n] != nullptr) { n++; if (n >= pHash->nSize) n = 0; @@ -124,13 +124,13 @@ rtl_str_hash_resize (sal_uInt32 nNewSize) for (i = 0; i < pHash->nSize; i++) { - if (pHash->pData[i] != NULL) + if (pHash->pData[i] != nullptr) rtl_str_hash_insert_nonequal (pNewHash, pHash->pData[i]); } pNewHash->nEntries = pHash->nEntries; free (pHash->pData); *pHash = *pNewHash; - pNewHash->pData = NULL; + pNewHash->pData = nullptr; rtl_str_hash_free (pNewHash); } @@ -160,7 +160,7 @@ rtl_str_hash_intern (rtl_uString *pString, rtl_str_hash_resize (getNextSize(pHash->nSize)); n = nHash % pHash->nSize; - while ((pHashStr = pHash->pData[n]) != NULL) { + while ((pHashStr = pHash->pData[n]) != nullptr) { if (compareEqual (pHashStr, pString)) { rtl_uString_acquire (pHashStr); @@ -173,11 +173,11 @@ rtl_str_hash_intern (rtl_uString *pString, if (!can_return) { - rtl_uString *pCopy = NULL; + rtl_uString *pCopy = nullptr; rtl_uString_newFromString( &pCopy, pString ); pString = pCopy; if (!pString) - return NULL; + return nullptr; } if (!SAL_STRING_IS_STATIC (pString)) @@ -198,25 +198,25 @@ rtl_str_hash_remove (rtl_uString *pString) StringHashTable *pHash = getHashTable(); n = nHash % pHash->nSize; - while ((pHashStr = pHash->pData[n]) != NULL) { + while ((pHashStr = pHash->pData[n]) != nullptr) { if (compareEqual (pHashStr, pString)) break; n++; if (n >= pHash->nSize) n = 0; } - OSL_ASSERT (pHash->pData[n] != 0); - if (pHash->pData[n] == NULL) + OSL_ASSERT (pHash->pData[n] != nullptr); + if (pHash->pData[n] == nullptr) return; - pHash->pData[n++] = NULL; + pHash->pData[n++] = nullptr; pHash->nEntries--; if (n >= pHash->nSize) n = 0; - while ((pHashStr = pHash->pData[n]) != NULL) { - pHash->pData[n] = NULL; + while ((pHashStr = pHash->pData[n]) != nullptr) { + pHash->pData[n] = nullptr; // FIXME: rather unsophisticated and N^2 in chain-length, but robust. rtl_str_hash_insert_nonequal (pHash, pHashStr); n++; diff --git a/sal/rtl/locale.cxx b/sal/rtl/locale.cxx index 8cdff09738fa..8274dde80099 100644 --- a/sal/rtl/locale.cxx +++ b/sal/rtl/locale.cxx @@ -43,9 +43,9 @@ struct RTL_HASHTABLE RTL_HASHENTRY** Table; }; -static RTL_HASHTABLE* g_pLocaleTable = NULL; +static RTL_HASHTABLE* g_pLocaleTable = nullptr; -static rtl_Locale* g_pDefaultLocale = NULL; +static rtl_Locale* g_pDefaultLocale = nullptr; /************************************************************************* */ @@ -97,7 +97,7 @@ extern "C" void rtl_hashtable_init(RTL_HASHTABLE** table, sal_Int8 sizeIndex) while (nSize) { - (*table)->Table[nSize - 1] = NULL; + (*table)->Table[nSize - 1] = nullptr; nSize--; } } @@ -114,7 +114,7 @@ extern "C" rtl_Locale* rtl_hashtable_add(RTL_HASHTABLE** table, rtl_Locale* valu sal_Int32 key = 0; if (!(*table)) - return NULL; + return nullptr; if ((*table)->Elements > ((*table)->Size / 2)) rtl_hashtable_grow(table); @@ -131,15 +131,15 @@ extern "C" rtl_Locale* rtl_hashtable_add(RTL_HASHTABLE** table, rtl_Locale* valu RTL_HASHENTRY *newEntry = static_cast<RTL_HASHENTRY*>(rtl_allocateMemory( sizeof(RTL_HASHENTRY) )); newEntry->Entry = value; - newEntry->Next = NULL; + newEntry->Next = nullptr; *pEntry = newEntry; (*table)->Elements++; - return NULL; + return nullptr; } sal_Bool rtl_hashtable_grow(RTL_HASHTABLE** table) { - RTL_HASHTABLE* pNewTable = NULL; + RTL_HASHTABLE* pNewTable = nullptr; sal_Int32 i = 0; rtl_hashtable_init(&pNewTable, (sal_Int8)((*table)->iSize + 1)); @@ -200,7 +200,7 @@ extern "C" sal_Bool rtl_hashtable_find(RTL_HASHTABLE * table, sal_Int32 key, sal */ void rtl_locale_init() { - OSL_ASSERT(g_pLocaleTable == 0); + OSL_ASSERT(g_pLocaleTable == nullptr); rtl_hashtable_init(&g_pLocaleTable, 1); } @@ -209,10 +209,10 @@ void rtl_locale_init() */ void rtl_locale_fini() { - if (g_pLocaleTable != 0) + if (g_pLocaleTable != nullptr) { rtl_hashtable_destroy (g_pLocaleTable); - g_pLocaleTable = 0; + g_pLocaleTable = nullptr; } } @@ -222,10 +222,10 @@ void rtl_locale_fini() rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant ) { sal_Unicode c = 0; - rtl_uString* sLanguage = NULL; - rtl_uString* sCountry = NULL; - rtl_uString* sVariant = NULL; - rtl_Locale *newLocale = NULL; + rtl_uString* sLanguage = nullptr; + rtl_uString* sCountry = nullptr; + rtl_uString* sVariant = nullptr; + rtl_Locale *newLocale = nullptr; sal_Int32 hashCode = -1; sal_Int32 key = 0; @@ -236,7 +236,7 @@ rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const s ensureLocaleSingleton(); if (!g_pLocaleTable) - return NULL; + return nullptr; hashCode = rtl_ustr_hashCode(language) ^ rtl_ustr_hashCode(country) ^ rtl_ustr_hashCode(variant); key = rtl_hashfunc(g_pLocaleTable, hashCode); diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index 3713247db95d..fd33130706e1 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -175,7 +175,7 @@ inline void doubleToString(StringT ** pResult, { // #i112652# XMLSchema-2 sal_Int32 nCapacity = RTL_CONSTASCII_LENGTH("NaN"); - if (pResultCapacity == 0) + if (pResultCapacity == nullptr) { pResultCapacity = &nCapacity; T::createBuffer(pResult, pResultCapacity); @@ -192,7 +192,7 @@ inline void doubleToString(StringT ** pResult, { // #i112652# XMLSchema-2 sal_Int32 nCapacity = RTL_CONSTASCII_LENGTH("-INF"); - if (pResultCapacity == 0) + if (pResultCapacity == nullptr) { pResultCapacity = &nCapacity; T::createBuffer(pResult, pResultCapacity); @@ -501,7 +501,7 @@ inline void doubleToString(StringT ** pResult, nExp % 10 + static_cast< typename T::Char >('0') ); } - if (pResultCapacity == 0) + if (pResultCapacity == nullptr) T::createString(pResult, pBuf, p - pBuf); else T::appendChars(pResult, pResultCapacity, &nResultOffset, pBuf, @@ -785,7 +785,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, if ( bSign ) fVal = -fVal; - if (pStatus != 0) + if (pStatus != nullptr) *pStatus = eStatus; if (pParsedEnd != 0) *pParsedEnd = p == p0 ? pBegin : p; diff --git a/sal/rtl/random.cxx b/sal/rtl/random.cxx index 6a8142ebf11d..d96f74d6be0f 100644 --- a/sal/rtl/random.cxx +++ b/sal/rtl/random.cxx @@ -312,7 +312,7 @@ rtlRandomError SAL_CALL rtl_random_addBytes ( RandomPool_Impl *pImpl = static_cast<RandomPool_Impl *>(Pool); const sal_uInt8 *pBuffer = static_cast<const sal_uInt8 *>(Buffer); - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Random_E_Argument; if(pImpl->m_hDigest) { @@ -330,7 +330,7 @@ rtlRandomError SAL_CALL rtl_random_getBytes ( RandomPool_Impl *pImpl = static_cast<RandomPool_Impl *>(Pool); sal_uInt8 *pBuffer = static_cast<sal_uInt8 *>(Buffer); - if ((pImpl == NULL) || (pBuffer == NULL)) + if ((pImpl == nullptr) || (pBuffer == nullptr)) return rtl_Random_E_Argument; if(pImpl->m_hDigest || !osl_get_system_random_data(static_cast<char*>(Buffer), Bytes)) diff --git a/sal/rtl/rtl_process.cxx b/sal/rtl/rtl_process.cxx index 4a052630dd17..5eb411ba72d5 100644 --- a/sal/rtl/rtl_process.cxx +++ b/sal/rtl/rtl_process.cxx @@ -31,7 +31,7 @@ namespace { class Id: private boost::noncopyable { public: - Id() { rtl_createUuid(uuid_, 0, false); } + Id() { rtl_createUuid(uuid_, nullptr, false); } void copy(sal_uInt8 * target) const { std::memcpy(target, uuid_, UUID_SIZE); } diff --git a/sal/rtl/strbuf.cxx b/sal/rtl/strbuf.cxx index b88b0d9585c1..374f329f5a55 100644 --- a/sal/rtl/strbuf.cxx +++ b/sal/rtl/strbuf.cxx @@ -78,7 +78,7 @@ void SAL_CALL rtl_stringbuffer_ensureCapacity if (minimumCapacity > *capacity) { rtl_String * pTmp = *This; - rtl_String * pNew = NULL; + rtl_String * pNew = nullptr; *capacity = ((*This)->length + 1) * 2; if (minimumCapacity > *capacity) /* still lower, set to the minimum capacity */ diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx index 3647908c3ada..98954fab90fa 100644 --- a/sal/rtl/string.cxx +++ b/sal/rtl/string.cxx @@ -89,11 +89,11 @@ sal_Int32 SAL_CALL rtl_str_valueOfFloat(sal_Char * pStr, float f) SAL_THROW_EXTERN_C() { assert(pStr); - rtl_String * pResult = NULL; + rtl_String * pResult = nullptr; sal_Int32 nLen; rtl_math_doubleToString( - &pResult, 0, 0, f, rtl_math_StringFormat_G, - RTL_STR_MAX_VALUEOFFLOAT - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, 0, + &pResult, nullptr, 0, f, rtl_math_StringFormat_G, + RTL_STR_MAX_VALUEOFFLOAT - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', nullptr, 0, sal_True); nLen = pResult->length; OSL_ASSERT(nLen < RTL_STR_MAX_VALUEOFFLOAT); @@ -106,11 +106,11 @@ sal_Int32 SAL_CALL rtl_str_valueOfDouble(sal_Char * pStr, double d) SAL_THROW_EXTERN_C() { assert(pStr); - rtl_String * pResult = NULL; + rtl_String * pResult = nullptr; sal_Int32 nLen; rtl_math_doubleToString( - &pResult, 0, 0, d, rtl_math_StringFormat_G, - RTL_STR_MAX_VALUEOFDOUBLE - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, + &pResult, nullptr, 0, d, rtl_math_StringFormat_G, + RTL_STR_MAX_VALUEOFDOUBLE - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', nullptr, 0, sal_True); nLen = pResult->length; OSL_ASSERT(nLen < RTL_STR_MAX_VALUEOFDOUBLE); @@ -123,14 +123,14 @@ float SAL_CALL rtl_str_toFloat(sal_Char const * pStr) SAL_THROW_EXTERN_C() { assert(pStr); return (float) rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), - '.', 0, 0, 0); + '.', 0, nullptr, nullptr); } double SAL_CALL rtl_str_toDouble(sal_Char const * pStr) SAL_THROW_EXTERN_C() { assert(pStr); return rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), '.', 0, - 0, 0); + nullptr, nullptr); } /* ======================================================================= */ @@ -227,7 +227,7 @@ bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, if ( *pTarget ) rtl_string_release( *pTarget ); *pTarget = rtl_string_ImplAlloc( nLength ); - OSL_ASSERT(*pTarget != NULL); + OSL_ASSERT(*pTarget != nullptr); pBuffer = (*pTarget)->buffer; do { @@ -266,8 +266,8 @@ bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, for (;;) { pTemp = rtl_string_ImplAlloc( nNewLen ); - OSL_ASSERT(pTemp != NULL); - nDestBytes = rtl_convertUnicodeToText( hConverter, 0, + OSL_ASSERT(pTemp != nullptr); + nDestBytes = rtl_convertUnicodeToText( hConverter, nullptr, pSource, nLength, pTemp->buffer, nNewLen, nFlags, @@ -296,7 +296,7 @@ bool SAL_CALL rtl_impl_convertUStringToString(rtl_String ** pTarget, if ( nNewLen > nDestBytes+8 ) { rtl_String* pTemp2 = rtl_string_ImplAlloc( nDestBytes ); - OSL_ASSERT(pTemp2 != NULL); + OSL_ASSERT(pTemp2 != nullptr); rtl_str_ImplCopy( pTemp2->buffer, pTemp->buffer, nDestBytes ); rtl_freeMemory( pTemp ); pTemp = pTemp2; @@ -347,8 +347,8 @@ void rtl_string_newReplaceFirst( sal_Int32 fromLength, char const * to, sal_Int32 toLength, sal_Int32 * index) SAL_THROW_EXTERN_C() { - assert(str != 0); - assert(index != 0); + assert(str != nullptr); + assert(index != nullptr); assert(*index >= 0 && *index <= str->length); assert(fromLength >= 0); assert(toLength >= 0); diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index 58e07585d41b..41ab63fd69bd 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -1150,8 +1150,8 @@ static IMPL_RTL_STRINGDATA* IMPL_RTL_STRINGNAME( ImplAlloc )( sal_Int32 nLen ) / sizeof (IMPL_RTL_STRCODE))) ? static_cast<IMPL_RTL_STRINGDATA *>(rtl_allocateMemory( sizeof (IMPL_RTL_STRINGDATA) + nLen * sizeof (IMPL_RTL_STRCODE))) - : NULL; - if (pData != NULL) { + : nullptr; + if (pData != nullptr) { pData->refCount = 1; pData->length = nLen; pData->buffer[nLen] = 0; @@ -1169,7 +1169,7 @@ static IMPL_RTL_STRCODE* IMPL_RTL_STRINGNAME( ImplNewCopy )( IMPL_RTL_STRINGDATA IMPL_RTL_STRCODE* pDest; const IMPL_RTL_STRCODE* pSrc; IMPL_RTL_STRINGDATA* pData = IMPL_RTL_STRINGNAME( ImplAlloc )( pStr->length ); - OSL_ASSERT(pData != NULL); + OSL_ASSERT(pData != nullptr); pDest = pData->buffer; pSrc = pStr->buffer; @@ -1251,7 +1251,7 @@ IMPL_RTL_STRINGDATA* SAL_CALL IMPL_RTL_STRINGNAME( alloc )( sal_Int32 nLen ) SAL_THROW_EXTERN_C() { if ( nLen < 0 ) - return NULL; + return nullptr; else return IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); } @@ -1270,7 +1270,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( new_WithLength )( IMPL_RTL_STRINGDATA** ppThi IMPL_RTL_STRINGNAME( release )( *ppThis ); *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); + OSL_ASSERT(*ppThis != nullptr); (*ppThis)->length = 0; IMPL_RTL_STRCODE* pTempStr = (*ppThis)->buffer; @@ -1296,7 +1296,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromString )( IMPL_RTL_STRINGDATA** ppThis pOrg = *ppThis; *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( pStr->length ); - OSL_ASSERT(*ppThis != NULL); + OSL_ASSERT(*ppThis != nullptr); rtl_str_ImplCopy( (*ppThis)->buffer, pStr->buffer, pStr->length ); RTL_LOG_STRING_NEW( *ppThis ); @@ -1334,7 +1334,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr )( IMPL_RTL_STRINGDATA** ppThis, pOrg = *ppThis; *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); + OSL_ASSERT(*ppThis != nullptr); pBuffer = (*ppThis)->buffer; do { @@ -1369,7 +1369,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr_WithLength )( IMPL_RTL_STRINGDATA* pOrg = *ppThis; *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); + OSL_ASSERT(*ppThis != nullptr); rtl_str_ImplCopy( (*ppThis)->buffer, pCharStr, nLen ); RTL_LOG_STRING_NEW( *ppThis ); @@ -1425,7 +1425,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromLiteral )( IMPL_RTL_STRINGDATA** ppThi IMPL_RTL_STRINGNAME( release )( *ppThis ); *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen + allocExtra ); - assert( *ppThis != NULL ); + assert( *ppThis != nullptr ); (*ppThis)->length = nLen; // fix after possible allocExtra != 0 (*ppThis)->buffer[nLen] = 0; @@ -1505,7 +1505,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newConcat )( IMPL_RTL_STRINGDATA** ppThis, else { IMPL_RTL_STRINGDATA* pTempStr = IMPL_RTL_STRINGNAME( ImplAlloc )( pLeft->length + pRight->length ); - OSL_ASSERT(pTempStr != NULL); + OSL_ASSERT(pTempStr != nullptr); rtl_str_ImplCopy( pTempStr->buffer, pLeft->buffer, pLeft->length ); rtl_str_ImplCopy( pTempStr->buffer+pLeft->length, pRight->buffer, pRight->length ); *ppThis = pTempStr; @@ -1600,7 +1600,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newReplaceStrAt )( IMPL_RTL_STRINGDATA** ppTh /* Alloc New Buffer */ *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); - OSL_ASSERT(*ppThis != NULL); + OSL_ASSERT(*ppThis != nullptr); pBuffer = (*ppThis)->buffer; if ( nIndex ) { diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx index ea895e5a8906..b028b3cf6664 100644 --- a/sal/rtl/uri.cxx +++ b/sal/rtl/uri.cxx @@ -156,7 +156,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd, sal_uInt32 nInfo; sal_Size nConverted; sal_Size nDstSize = rtl_convertTextToUnicode( - aConverter, 0, aBuf.getStr(), aBuf.getLength(), aDst, + aConverter, nullptr, aBuf.getStr(), aBuf.getLength(), aDst, SAL_N_ELEMENTS( aDst ), (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR @@ -289,7 +289,7 @@ bool writeEscapeChar(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nInfo; sal_Size nConverted; sal_Size nDstSize = rtl_convertUnicodeToText( - aConverter, 0, aSrc, nSrcSize, aDst, sizeof aDst, + aConverter, nullptr, aSrc, nSrcSize, aDst, sizeof aDst, RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR | RTL_UNICODETOTEXT_FLAGS_FLUSH, @@ -318,9 +318,9 @@ struct Component sal_Unicode const * pBegin; sal_Unicode const * pEnd; - inline Component(): pBegin(0), pEnd(0) {} + inline Component(): pBegin(nullptr), pEnd(nullptr) {} - inline bool isPresent() const { return pBegin != 0; } + inline bool isPresent() const { return pBegin != nullptr; } inline sal_Int32 getLength() const; }; diff --git a/sal/rtl/ustrbuf.cxx b/sal/rtl/ustrbuf.cxx index 7f5d698c76ec..89b897f21573 100644 --- a/sal/rtl/ustrbuf.cxx +++ b/sal/rtl/ustrbuf.cxx @@ -62,7 +62,7 @@ rtl_uString * SAL_CALL rtl_uStringBuffer_makeStringAndClear( rtl_uString ** ppTh assert(nCapacity); // avoid an un-necessary atomic ref/unref pair rtl_uString *pStr = *ppThis; - *ppThis = NULL; + *ppThis = nullptr; rtl_uString_new (ppThis); *nCapacity = 0; @@ -103,7 +103,7 @@ void SAL_CALL rtl_uStringbuffer_ensureCapacity if (minimumCapacity > *capacity) { rtl_uString * pTmp = *This; - rtl_uString * pNew = NULL; + rtl_uString * pNew = nullptr; *capacity = ((*This)->length + 1) * 2; if (minimumCapacity > *capacity) /* still lower, set to the minimum capacity */ diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx index 9648fc63bfa7..16e9b87b6288 100644 --- a/sal/rtl/ustring.cxx +++ b/sal/rtl/ustring.cxx @@ -149,11 +149,11 @@ sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(sal_Unicode * pStr, float f) SAL_THROW_EXTERN_C() { assert(pStr); - rtl_uString * pResult = NULL; + rtl_uString * pResult = nullptr; sal_Int32 nLen; rtl_math_doubleToUString( - &pResult, 0, 0, f, rtl_math_StringFormat_G, - RTL_USTR_MAX_VALUEOFFLOAT - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, + &pResult, nullptr, 0, f, rtl_math_StringFormat_G, + RTL_USTR_MAX_VALUEOFFLOAT - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', nullptr, 0, sal_True); nLen = pResult->length; OSL_ASSERT(nLen < RTL_USTR_MAX_VALUEOFFLOAT); @@ -166,11 +166,11 @@ sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(sal_Unicode * pStr, double d) SAL_THROW_EXTERN_C() { assert(pStr); - rtl_uString * pResult = NULL; + rtl_uString * pResult = nullptr; sal_Int32 nLen; rtl_math_doubleToUString( - &pResult, 0, 0, d, rtl_math_StringFormat_G, - RTL_USTR_MAX_VALUEOFDOUBLE - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', 0, + &pResult, nullptr, 0, d, rtl_math_StringFormat_G, + RTL_USTR_MAX_VALUEOFDOUBLE - RTL_CONSTASCII_LENGTH("-x.E-xxx"), '.', nullptr, 0, sal_True); nLen = pResult->length; OSL_ASSERT(nLen < RTL_USTR_MAX_VALUEOFDOUBLE); @@ -199,14 +199,14 @@ float SAL_CALL rtl_ustr_toFloat(sal_Unicode const * pStr) SAL_THROW_EXTERN_C() assert(pStr); return doubleToFloat(rtl_math_uStringToDouble(pStr, pStr + rtl_ustr_getLength(pStr), - '.', 0, 0, 0)); + '.', 0, nullptr, nullptr)); } double SAL_CALL rtl_ustr_toDouble(sal_Unicode const * pStr) SAL_THROW_EXTERN_C() { assert(pStr); return rtl_math_uStringToDouble(pStr, pStr + rtl_ustr_getLength(pStr), '.', - 0, 0, 0); + 0, nullptr, nullptr); } /* ======================================================================= */ @@ -543,7 +543,7 @@ void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis, rtl_uString_release( *ppThis ); *ppThis = rtl_uString_ImplAlloc( nLen ); - OSL_ASSERT(*ppThis != NULL); + OSL_ASSERT(*ppThis != nullptr); if ( (*ppThis) ) { sal_Unicode* pBuffer = (*ppThis)->buffer; @@ -573,7 +573,7 @@ void SAL_CALL rtl_uString_newFromCodePoints( rtl_uString_new(newString); return; } - if (*newString != NULL) { + if (*newString != nullptr) { rtl_uString_release(*newString); } n = codePointCount; @@ -589,11 +589,11 @@ void SAL_CALL rtl_uString_newFromCodePoints( sal_Int32 -2): */ if (n < 0) { // coverity[dead_error_begin] - assumes wrap around - *newString = NULL; + *newString = nullptr; return; } *newString = rtl_uString_ImplAlloc(n); - if (*newString == NULL) { + if (*newString == nullptr) { return; } p = (*newString)->buffer; @@ -685,7 +685,7 @@ static void rtl_string2UString_status( rtl_uString** ppThis, if ( !nLen ) { rtl_uString_new( ppThis ); - if (pInfo != NULL) { + if (pInfo != nullptr) { *pInfo = 0; } } @@ -699,8 +699,8 @@ static void rtl_string2UString_status( rtl_uString** ppThis, { sal_Unicode* pBuffer; *ppThis = rtl_uString_ImplAlloc( nLen ); - if (*ppThis == NULL) { - if (pInfo != NULL) { + if (*ppThis == nullptr) { + if (pInfo != nullptr) { *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; } @@ -724,7 +724,7 @@ static void rtl_string2UString_status( rtl_uString** ppThis, nLenCopy--; } while (nLenCopy); - if (pInfo != NULL) { + if (pInfo != nullptr) { *pInfo = 0; } RTL_LOG_STRING_NEW( *ppThis ); @@ -733,7 +733,7 @@ static void rtl_string2UString_status( rtl_uString** ppThis, retry: { rtl_uString* pTemp; - rtl_uString* pTemp2 = NULL; + rtl_uString* pTemp2 = nullptr; rtl_TextToUnicodeConverter hConverter; sal_uInt32 nInfo; sal_Size nSrcBytes; @@ -753,9 +753,9 @@ retry: { sal_Unicode* pBuffer; *ppThis = rtl_uString_ImplAlloc( nLen ); - if (*ppThis == NULL) + if (*ppThis == nullptr) { - if (pInfo != NULL) { + if (pInfo != nullptr) { *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; } @@ -771,7 +771,7 @@ retry: nLen--; } while ( nLen ); - if (pInfo != NULL) { + if (pInfo != nullptr) { *pInfo = 0; } RTL_LOG_STRING_NEW( *ppThis ); @@ -785,14 +785,14 @@ retry: hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); pTemp = rtl_uString_ImplAlloc( nNewLen ); - if (pTemp == NULL) { - if (pInfo != NULL) { + if (pTemp == nullptr) { + if (pInfo != nullptr) { *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; } return; } - nDestChars = rtl_convertTextToUnicode( hConverter, 0, + nDestChars = rtl_convertTextToUnicode( hConverter, nullptr, pStr, nLen, pTemp->buffer, nNewLen, nCvtFlags, @@ -807,14 +807,14 @@ retry: rtl_freeMemory( pTemp ); nNewLen += 8; pTemp = rtl_uString_ImplAlloc( nNewLen ); - if (pTemp == NULL) { - if (pInfo != NULL) { + if (pTemp == nullptr) { + if (pInfo != nullptr) { *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL; } return; } - nDestChars = rtl_convertTextToUnicode( hConverter, 0, + nDestChars = rtl_convertTextToUnicode( hConverter, nullptr, pStr, nLen, pTemp->buffer, nNewLen, nCvtFlags, @@ -830,7 +830,7 @@ retry: { pTemp2 = rtl_uString_ImplAlloc( nDestChars ); } - if (pTemp2 != NULL) + if (pTemp2 != nullptr) { rtl_str_ImplCopy(pTemp2->buffer, pTemp->buffer, nDestChars); rtl_freeMemory(pTemp); @@ -863,7 +863,7 @@ void SAL_CALL rtl_string2UString( rtl_uString** ppThis, assert(ppThis); assert(nLen >= 0); rtl_string2UString_status( ppThis, pStr, nLen, eTextEncoding, - nCvtFlags, NULL ); + nCvtFlags, nullptr ); } /* ----------------------------------------------------------------------- */ @@ -876,7 +876,7 @@ enum StrLifecycle { static oslMutex getInternMutex() { - static oslMutex pPoolGuard = NULL; + static oslMutex pPoolGuard = nullptr; if( !pPoolGuard ) { oslMutex pGlobalGuard; @@ -934,7 +934,7 @@ void SAL_CALL rtl_uString_intern( rtl_uString ** newStr, else { rtl_uString *pOrg = *newStr; - *newStr = NULL; + *newStr = nullptr; rtl_ustring_intern_internal( newStr, str, CANNOT_RETURN ); if (pOrg) rtl_uString_release (pOrg); @@ -979,7 +979,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, if (*newStr) { rtl_uString_release (*newStr); - *newStr = NULL; + *newStr = nullptr; } if ( len < 256 ) @@ -1015,7 +1015,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); rtl_convertTextToUnicode( - hConverter, 0, str, len, pScratch->buffer, ulen, convertFlags, &nInfo, &nSrcBytes ); + hConverter, nullptr, str, len, pScratch->buffer, ulen, convertFlags, &nInfo, &nSrcBytes ); rtl_destroyTextToUnicodeConverter( hConverter ); if (pInfo) @@ -1029,7 +1029,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, /* FIXME: we want a nice UTF-8 / alloca shortcut here */ } - scratch = NULL; + scratch = nullptr; rtl_string2UString_status( &scratch, str, len, eTextEncoding, convertFlags, pInfo ); if (!scratch) { @@ -1043,7 +1043,7 @@ internRelease (rtl_uString *pThis) { oslMutex pPoolMutex; - rtl_uString *pFree = NULL; + rtl_uString *pFree = nullptr; if ( SAL_STRING_REFCOUNT( osl_atomic_decrement( &(pThis->refCount) ) ) == 0) { @@ -1078,7 +1078,7 @@ sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints( sal_Int32 n; sal_Unicode cu; sal_uInt32 cp; - assert(string != NULL && indexUtf16 != NULL); + assert(string != nullptr && indexUtf16 != nullptr); n = *indexUtf16; assert(n >= 0 && n <= string->length); while (incrementCodePoints < 0) { @@ -1130,11 +1130,11 @@ void rtl_uString_newReplaceFirst( rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from, rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C() { - assert(str != 0); - assert(index != 0); + assert(str != nullptr); + assert(index != nullptr); assert(*index >= 0 && *index <= str->length); - assert(from != 0); - assert(to != 0); + assert(from != nullptr); + assert(to != nullptr); sal_Int32 i = rtl_ustr_indexOfStr_WithLength( str->buffer + *index, str->length - *index, from->buffer, from->length); if (i == -1) { @@ -1172,11 +1172,11 @@ void rtl_uString_newReplaceFirstAsciiL( sal_Int32 fromLength, rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C() { - assert(str != 0); - assert(index != 0); + assert(str != nullptr); + assert(index != nullptr); assert(*index >= 0 && *index <= str->length); assert(fromLength >= 0); - assert(to != 0); + assert(to != nullptr); sal_Int32 i = rtl_ustr_indexOfAscii_WithLength( str->buffer + *index, str->length - *index, from, fromLength); if (i == -1) { @@ -1214,10 +1214,10 @@ void rtl_uString_newReplaceFirstToAsciiL( char const * to, sal_Int32 toLength, sal_Int32 * index) SAL_THROW_EXTERN_C() { - assert(str != 0); - assert(index != 0); + assert(str != nullptr); + assert(index != nullptr); assert(*index >= 0 && *index <= str->length); - assert(from != 0); + assert(from != nullptr); assert(toLength >= 0); sal_Int32 i = rtl_ustr_indexOfStr_WithLength( str->buffer + *index, str->length - *index, from->buffer, from->length); @@ -1257,11 +1257,11 @@ void rtl_uString_newReplaceFirstAsciiLAsciiL( sal_Int32 fromLength, char const * to, sal_Int32 toLength, sal_Int32 * index) SAL_THROW_EXTERN_C() { - assert(str != 0); - assert(index != 0); + assert(str != nullptr); + assert(index != nullptr); assert(*index >= 0 && *index <= str->length); assert(fromLength >= 0); - assert(to != 0); + assert(to != nullptr); assert(toLength >= 0); sal_Int32 i = rtl_ustr_indexOfAscii_WithLength( str->buffer + *index, str->length - *index, from, fromLength); @@ -1307,7 +1307,7 @@ void rtl_uString_newReplaceAllFromIndex( rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from, rtl_uString const * to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C() { - assert(to != 0); + assert(to != nullptr); assert(fromIndex >= 0 && fromIndex <= str->length); rtl_uString_assign(newStr, str); for (sal_Int32 i = fromIndex;; i += to->length) { @@ -1322,7 +1322,7 @@ void rtl_uString_newReplaceAllAsciiL( rtl_uString ** newStr, rtl_uString * str, char const * from, sal_Int32 fromLength, rtl_uString const * to) SAL_THROW_EXTERN_C() { - assert(to != 0); + assert(to != nullptr); rtl_uString_assign(newStr, str); for (sal_Int32 i = 0;; i += to->length) { rtl_uString_newReplaceFirstAsciiL( @@ -1337,7 +1337,7 @@ void rtl_uString_newReplaceAllToAsciiL( rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from, char const * to, sal_Int32 toLength) SAL_THROW_EXTERN_C() { - assert(from != 0); + assert(from != nullptr); rtl_uString_assign(newStr, str); for (sal_Int32 i = 0;; i += toLength) { rtl_uString_newReplaceFirstToAsciiL( diff --git a/sal/rtl/uuid.cxx b/sal/rtl/uuid.cxx index 8eb0566e9e2f..b3197d14a117 100644 --- a/sal/rtl/uuid.cxx +++ b/sal/rtl/uuid.cxx @@ -94,10 +94,10 @@ extern "C" void SAL_CALL rtl_createUuid( sal_uInt8 *pTargetUUID , { { osl::MutexGuard g(osl::Mutex::getGlobalMutex()); - static rtlRandomPool pool = NULL; - if (pool == NULL) { + static rtlRandomPool pool = nullptr; + if (pool == nullptr) { pool = rtl_random_createPool(); - if (pool == NULL) { + if (pool == nullptr) { abort(); // only possible way to signal failure here (rtl_createUuid // being part of a fixed C API) |