Rename STRING_ASSERT_SLOW into M_ASERT_SLOW
This commit is contained in:
1 parent
8e15a8cfe9
commit
d169a06f79
5 files changed
+14
-11
No files matched your search
@@ -279,6 +279,16 @@ M_BEGIN_PROTECTED_CODE
|
||||
#endif
|
||||
|
||||
|
||||
/* If within the M*LIB tests, perform additional (potentialy slow) checks */
|
||||
#ifndef M_ASSERT_SLOW
|
||||
# if defined(M_USE_ADDITIONAL_CHECKS) && M_USE_ADDITIONAL_CHECKS
|
||||
# define M_ASSERT_SLOW(n) assert(n)
|
||||
# else
|
||||
# define M_ASSERT_SLOW(n) (void) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Always perform a runtime check of the given condition
|
||||
* NOTE: Can be overiden by user if it needs to keep finer access
|
||||
* on the assertions or display message on another device.
|
||||
|
||||
+1
-1
@@ -181,7 +181,7 @@ m_serial_bin_write_float(m_serial_write_t serial, const long double data, const
|
||||
static inline m_serial_return_code_t
|
||||
m_serial_bin_write_string(m_serial_write_t serial, const char data[], size_t length)
|
||||
{
|
||||
STRINGI_ASSERT_SLOW(length == strlen(data) );
|
||||
M_ASSERT_SLOW(length == strlen(data) );
|
||||
FILE *f = (FILE *)serial->data[0].p;
|
||||
M_ASSERT(f != NULL && data != NULL);
|
||||
// Write first the number of (non null) characters
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ m_serial_json_write_float(m_serial_write_t serial, const long double data, const
|
||||
static inline m_serial_return_code_t
|
||||
m_serial_json_write_string(m_serial_write_t serial, const char data[], size_t length)
|
||||
{
|
||||
STRINGI_ASSERT_SLOW(length == strlen(data) );
|
||||
M_ASSERT_SLOW(length == strlen(data) );
|
||||
FILE *f = (FILE *)serial->data[0].p;
|
||||
M_ASSERT(f != NULL && data != NULL);
|
||||
/* HACK: Build dummy string to reuse string_out_str */
|
||||
|
||||
+1
-8
@@ -37,19 +37,12 @@ M_BEGIN_PROTECTED_CODE
|
||||
|
||||
/********************************** INTERNAL ************************************/
|
||||
|
||||
/* If within the string tests, perform additional (potentialy slow) checks */
|
||||
#ifdef STRING_WITHIN_TEST
|
||||
# define STRINGI_ASSERT_SLOW(n) M_ASSERT(n)
|
||||
#else
|
||||
# define STRINGI_ASSERT_SLOW(n) (void) 0
|
||||
#endif
|
||||
|
||||
// This macro defines the contract of a string.
|
||||
// Note: A ==> B is represented as not(A) or B
|
||||
// Note: use of strlen can slow down a lot the program in some cases.
|
||||
#define STRINGI_CONTRACT(v) do { \
|
||||
M_ASSERT (v != NULL); \
|
||||
STRINGI_ASSERT_SLOW (string_size(v) == strlen(string_get_cstr(v))); \
|
||||
M_ASSERT_SLOW (string_size(v) == strlen(string_get_cstr(v))); \
|
||||
M_ASSERT (string_get_cstr(v)[string_size(v)] == 0); \
|
||||
M_ASSERT (string_size(v) < string_capacity(v)); \
|
||||
M_ASSERT (string_capacity(v) < sizeof (string_heap_ct) || !stringi_stack_p(v)); \
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define STRING_WITHIN_TEST
|
||||
#define M_USE_ADDITIONAL_CHECKS 1
|
||||
#include "m-string.h"
|
||||
|
||||
BOUNDED_STRING_DEF(string16, 16)
|
||||
|
||||
Reference in new issue
Block a user