From 5a3890f7b3451c5a21bdf3161f675917cceeee8c Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Sun, 18 Oct 2015 08:32:01 +0000 Subject: [PATCH] Upadted comments, reformatted. FossilOrigin-Name: e040796769d7b529f079874260580ae88eef67c2fa97c8516984fdc19bb42116 --- src/capwap/cw_load_file.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/capwap/cw_load_file.c b/src/capwap/cw_load_file.c index 5cb1cd5d..25fa2e64 100644 --- a/src/capwap/cw_load_file.c +++ b/src/capwap/cw_load_file.c @@ -1,5 +1,4 @@ #include -#include #include /** @@ -11,31 +10,33 @@ * @param filename name of file to load * @param size variable which receives the size of the file in bytes * @return a pointer to the memory where the file was loaded in \n - * The memory must be freed using free. + * The memory allocated returned in data must be freed using free. * * Eexample: * \code #include "capwap/file.h" size_t bytes; char * data = cw_load_file("file.txt",&bytes); - if (data) + if (data){ + // Do something with data ... free (data); + } \endcode - */ -char *cw_load_file(const char *filename,size_t *size) + */ +char *cw_load_file(const char *filename, size_t * size) { - FILE * infile = fopen(filename,"rb"); - if ( !infile) + FILE *infile = fopen(filename, "rb"); + if (!infile) return NULL; - fseek(infile,0,SEEK_END); + fseek(infile, 0, SEEK_END); *size = ftell(infile); char *buf = malloc(*size); - if (!buf) + if (!buf) goto errX; - fseek(infile,0,SEEK_SET); - *size = fread(buf,1,*size,infile); -errX: + fseek(infile, 0, SEEK_SET); + *size = fread(buf, 1, *size, infile); + errX: fclose(infile); @@ -43,13 +44,13 @@ errX: } -int cw_save_file(const char *filename, char *data,int len) +int cw_save_file(const char *filename, char *data, int len) { - FILE *outfile = fopen(filename,"wb"); + FILE *outfile = fopen(filename, "wb"); if (!outfile) return 0; - int bytes = fwrite(data,1,len,outfile); + int bytes = fwrite(data, 1, len, outfile); fclose(outfile); return bytes; }