From a3b7d48d5e9ee28751bb43297e8abdbd31778394 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 14 Aug 2020 07:54:28 +0200 Subject: Some cleanups. --- examples/geek4.c | 4 +++- examples/geek5.c | 4 ++-- examples/geek6.c | 2 +- examples/geek7.c | 2 +- stc/cbitset.h | 1 + stc/cdefs.h | 6 +++--- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/geek4.c b/examples/geek4.c index 3672563d..b0a57844 100644 --- a/examples/geek4.c +++ b/examples/geek4.c @@ -152,7 +152,9 @@ int main() // C++ implementation of the approach -#include +#include +#include +#include using namespace std; // Function to return the count of common words diff --git a/examples/geek5.c b/examples/geek5.c index cbfc40e6..67f5d097 100644 --- a/examples/geek5.c +++ b/examples/geek5.c @@ -37,7 +37,7 @@ int NumOccurrences(const char* arr[], int n, const char* str, int L, int R) // If current string doesn't // have an entry in the map // then create the entry - if (it == c_nullptr) { + if (it == NULL) { cvec_i A = cvec_init; cvec_i_push_back(&A, i + 1); cmap_sv_put(&M, temp, A); @@ -51,7 +51,7 @@ int NumOccurrences(const char* arr[], int n, const char* str, int L, int R) // If the given string is not // present in the array - if (it == c_nullptr) + if (it == NULL) return 0; // If the given string is present diff --git a/examples/geek6.c b/examples/geek6.c index b3991e99..db0b3bcf 100644 --- a/examples/geek6.c +++ b/examples/geek6.c @@ -52,7 +52,7 @@ int missingNumber(int a[], int n) // Return the first value starting // from 1 which does not exists in map while (1) { - if (cset_i_find(&mp, index) == c_nullptr) { + if (cset_i_find(&mp, index) == NULL) { return index; } diff --git a/examples/geek7.c b/examples/geek7.c index 0976bf80..9a60c0a9 100644 --- a/examples/geek7.c +++ b/examples/geek7.c @@ -49,7 +49,7 @@ void findElementsAfterDel(int arr[], int m, int del[], // Search if the element is present cmap_ii_entry_t *e = cmap_ii_find(&mp, arr[i]); - if (e != c_nullptr) { + if (e != NULL) { // Decrement its frequency e->value--; diff --git a/stc/cbitset.h b/stc/cbitset.h index 8af4bfcb..8e443d55 100644 --- a/stc/cbitset.h +++ b/stc/cbitset.h @@ -188,6 +188,7 @@ STC_API size_t cbitset_count(cbitset_t s) { } #define _cbitset_SETOP(OPR) \ + assert(s.size == other.size); \ if (s.size == 0) return false; /* ? */ \ size_t n = ((s.size + 63) >> 6) - 1; \ for (size_t i=0; i