fixed -r and -d
This commit is contained in:
@ -37,8 +37,8 @@ fileT* createFileT(char *f, int O_LOCK, int client, int open){
|
||||
strncpy(file->filepath, f, strnlen(f, MAXNAMELEN));
|
||||
|
||||
// in seguito semplicemente facciamo realloc
|
||||
if ((file->data = malloc(1)) == NULL) {
|
||||
perror("Malloc content");
|
||||
if ((file->data = calloc(1, sizeof(char))) == NULL) {
|
||||
perror("Calloc content");
|
||||
return NULL;
|
||||
}
|
||||
return file;
|
||||
@ -51,7 +51,9 @@ int writeFileT(fileT *f, void *data, size_t size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = (size == 0)?1:size;
|
||||
if(size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((f->data = realloc(f->data, f->valid + size)) == NULL) {
|
||||
perror("Realloc content");
|
||||
|
||||
Reference in New Issue
Block a user