bug fixes and test2

This commit is contained in:
elvis
2022-04-23 17:43:38 +02:00
parent 11a5dae9e9
commit 4fe23200bc
37 changed files with 66 additions and 11 deletions

View File

@ -1,4 +1,4 @@
#define _POSIX_C_SOURCE 200112L
#define _POSIX_C_SOURCE 200809L
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
@ -106,12 +106,12 @@ size_t taglia_log(taglia_t *taglia, char *buf) {
size_t n, m;
pthread_mutex_lock(&taglia->m);
if((n = fwrite(buff, sizeof(char), sizeof(buff), taglia->file)) < 0){
if((n = fwrite(buff, sizeof(char), strnlen(buff, sizeof(buff)), taglia->file)) < 0){
perror("ERROR: fwrite");
goto _error_taglia_log_mutex;
}
if((m = fwrite(buf, sizeof(char), strlen(buff)+1, taglia->file)) < 0){
if((m = fwrite(buf, sizeof(char), strlen(buf)+1, taglia->file)) < 0){
// strlen conta il numero di caratteri senza EOF quindi aggiungiamo 1
perror("ERROR: fwrite");
goto _error_taglia_log_mutex;