comments with space

This commit is contained in:
root
2022-04-12 23:03:20 +03:00
parent 41f32f4f8c
commit 662cb7fc40
22 changed files with 76 additions and 75 deletions

View File

@@ -10,7 +10,7 @@ extern "C" {
#include "cptr.h"
// executes codeblock and prints execution time
#ifdef CLOCK_REALTIME //non-standard high-precision clock
#ifdef CLOCK_REALTIME // non-standard high-precision clock
#define optime(opname,repeats,codeblock) ({\
struct timespec start, stop;\
clock_gettime(CLOCK_REALTIME, &start);\
@@ -20,7 +20,7 @@ extern "C" {
double t=(double)(stop.tv_sec-start.tv_sec+(double)(stop.tv_nsec-start.tv_nsec)/1000000000)/repeats;\
printf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
})
#else //
#else // standard clock which works worse then previous
#define optime(opname,repeats,codeblock) ({\
clock_t start=clock();\
for(uint64 ___OPREP=0;___OPREP<(uint64)repeats;___OPREP++)\

View File

@@ -1,13 +1,13 @@
#include "base.h"
//returns length of string (without \0)
// returns length of string (without \0)
uint32 cptr_length(char* str){
uint32 len=0;
while(*(str++)) len++;
return len;
}
//allocates new char[] and copies src there
// allocates new char[] and copies src there
char* cptr_copy(char* src){
uint32 len=cptr_length(src)+1;
char* dst=malloc(len);
@@ -16,7 +16,7 @@ char* cptr_copy(char* src){
return dst;
}
//compares two char buffers, NullPtr-friendly
// compares two char buffers, NullPtr-friendly
bool cptr_compare(char* key0, char* key1){
if(!key0) return key1 ? false : true;
if(!key1) return false;
@@ -26,7 +26,7 @@ bool cptr_compare(char* key0, char* key1){
return true;
}
//multiplies char n times
// multiplies char n times
char* char_multiply(char c, uint32 n){
char* rez=malloc(n+1);
rez[n]=0;

View File

@@ -6,16 +6,16 @@ extern "C" {
#include "types.h"
//returns length of string (without \0)
// returns length of string (without \0)
uint32 cptr_length(char* str);
//allocates new char[] and copies src there
// allocates new char[] and copies src there
char* cptr_copy(char* src);
//compares two char buffers, NullPtr-friendly
// compares two char buffers, NullPtr-friendly
bool cptr_compare(char* key0, char* key1);
//multiplies char n times
// multiplies char n times
char* char_multiply(char c, uint32 n);
#if __cplusplus

View File

@@ -8,7 +8,7 @@ extern "C" {
#include "types.h"
typedef enum err_t {
SUCCESS, //not an error
SUCCESS, // not an error
ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX, ERR_NOTIMPLEMENTED, ERR_NULLPTR, ERR_ENDOFSTR
} err_t;

View File

@@ -45,7 +45,7 @@ const char* my_type_name(my_type t){
}
}
//frees VoidPtr value or does nothing if type isn't pointer
// frees VoidPtr value or does nothing if type isn't pointer
void Unitype_free(Unitype u){
switch (u.type) {
case Null:

View File

@@ -47,7 +47,7 @@ static const Unitype UniFalse={.Bool=false,.type=Bool};
#define Uni(TYPE,VAL) (Unitype){.type=TYPE,.TYPE=VAL}
#define UniPtr(TYPE,VAL) (Unitype){.type=TYPE,.VoidPtr=VAL}
//frees VoidPtr value or does nothing if type isn't pointer
// frees VoidPtr value or does nothing if type isn't pointer
void Unitype_free(Unitype u);
void printuni(Unitype v);
void sprintuni(char* s, Unitype v);