Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
src/network.c : 0
Browse files Browse the repository at this point in the history
malloc to calloc
  • Loading branch information
h4child committed Mar 4, 2018
1 parent 0f8dfc6 commit 25a0470
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
12 changes: 0 additions & 12 deletions src/framebot.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ Framebot *get_updates (Bot *bot, Framebot *framebot, long int offset, long int l

if( !framebot ){
framebot = (Framebot *)calloc(1, sizeof( Framebot ));

/* initialize */
framebot->update_id = 0;
framebot->message = NULL;
framebot->edited_message = NULL;
framebot->channel_post = NULL;
framebot->edited_channel_post = NULL;
framebot->inline_query = NULL;
framebot->chosen_inline_result = NULL;
framebot->callback_query = NULL;
framebot->shipping_query = NULL;
framebot->pre_checkout_query = NULL;
}

if(!s_json){
Expand Down
3 changes: 0 additions & 3 deletions src/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ refjson * load(char *json){
refjson * s_json;

s_json = (refjson *)calloc(1, sizeof(refjson));
s_json->root = NULL;
s_json->content = NULL;

s_json->root = json_loads(json, 0, &error);

Expand Down Expand Up @@ -84,7 +82,6 @@ void error_parse(refjson * json){

error(json_integer_value(error_code), json_string_value(description));

close_json(json);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ void network_init(){


MemStore * mem_store() {
MemStore *mem = (MemStore *)malloc(sizeof(MemStore));
MemStore *mem = (MemStore *)calloc(1, sizeof(MemStore));

mem->content = (char *)malloc(1);
mem->content = (char *)calloc(1, 1);
mem->size = 0;

return mem;
Expand Down Expand Up @@ -46,7 +46,7 @@ size_t mem_write_callback(void *data, size_t size, size_t nmemb, void *userp) {
MemStore * call_method(const char *token, char *method){
CURLcode res;
size_t url_size = API_URL_LEN + strlen( token ) + strlen( method ) + 2;
char * url = ( char * ) malloc( url_size );
char * url = ( char * ) calloc(1, url_size );

strcpy( url, API_URL );
strcat( url, token );
Expand Down Expand Up @@ -84,7 +84,7 @@ char * call_method_download(const char * token, char * dir, File *ofile){
char * namefile, *path, *url;

url_size = API_URL_FILE_LEN + strlen(token) + strlen(ofile->file_path) + 2;
url = (char *)malloc(url_size);
url = (char *)calloc(1, url_size);

strcpy(url, API_URL_FILE);
strcat(url, token);
Expand Down Expand Up @@ -112,7 +112,7 @@ char * call_method_download(const char * token, char * dir, File *ofile){
else
path_len = strlen(dir) + strlen(namefile) + 2;

path = malloc(path_len);
path = calloc(1, path_len);
if(!path)
return NULL;

Expand Down Expand Up @@ -503,7 +503,7 @@ MemStore * call_method_input_file(const char * token, IFile ifile){

buff = mem_store();
url_size = API_URL_LEN + strlen(token) + strlen(method) + 2;
url = malloc(url_size);
url = calloc(1, url_size);

strcpy(url, API_URL);
strcat(url, token);
Expand Down Expand Up @@ -542,7 +542,7 @@ MemStore * call_method_input_file(const char * token, IFile ifile){

MemStore *call_method_wp(char *token, char *method, char *params) {
size_t len = strlen(method) + strlen(params) + 1;
char *tmp = (char *)malloc(len);
char *tmp = (char *)calloc(1, len);

MemStore *ms = call_method(token, tmp);

Expand Down

0 comments on commit 25a0470

Please sign in to comment.