mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
saving weight files as binaries, hell yeah
This commit is contained in:
22
src/utils.c
22
src/utils.c
@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
|
||||
@ -148,6 +149,27 @@ char *fgetl(FILE *fp)
|
||||
return line;
|
||||
}
|
||||
|
||||
void read_all(int fd, char *buffer, size_t bytes)
|
||||
{
|
||||
size_t n = 0;
|
||||
while(n < bytes){
|
||||
int next = read(fd, buffer + n, bytes-n);
|
||||
if(next <= 0) error("read failed");
|
||||
n += next;
|
||||
}
|
||||
}
|
||||
|
||||
void write_all(int fd, char *buffer, size_t bytes)
|
||||
{
|
||||
size_t n = 0;
|
||||
while(n < bytes){
|
||||
size_t next = write(fd, buffer + n, bytes-n);
|
||||
if(next <= 0) error("write failed");
|
||||
n += next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *copy_string(char *s)
|
||||
{
|
||||
char *copy = malloc(strlen(s)+1);
|
||||
|
Reference in New Issue
Block a user