@@ -13,6 +13,7 @@ apiClient_t *apiClient_create() {
1313 apiClient -> sslConfig = NULL ;
1414 apiClient -> dataReceived = NULL ;
1515 apiClient -> dataReceivedLen = 0 ;
16+ apiClient -> data_callback_func = NULL ;
1617 apiClient -> response_code = 0 ;
1718 apiClient -> apiKeys_api_key = NULL ;
1819 apiClient -> accessToken = NULL ;
@@ -40,6 +41,7 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
4041
4142 apiClient -> dataReceived = NULL ;
4243 apiClient -> dataReceivedLen = 0 ;
44+ apiClient -> data_callback_func = NULL ;
4345 apiClient -> response_code = 0 ;
4446 if (apiKeys_api_key != NULL ) {
4547 apiClient -> apiKeys_api_key = list_create ();
@@ -61,6 +63,7 @@ void apiClient_free(apiClient_t *apiClient) {
6163 if (apiClient -> basePath ) {
6264 free (apiClient -> basePath );
6365 }
66+ apiClient -> data_callback_func = NULL ;
6467 if (apiClient -> apiKeys_api_key ) {
6568 listEntry_t * listEntry = NULL ;
6669 list_ForEach (listEntry , apiClient -> apiKeys_api_key ) {
@@ -464,6 +467,10 @@ size_t writeDataCallback(void *buffer, size_t size, size_t nmemb, void *userp) {
464467 apiClient -> dataReceived = (char * )realloc ( apiClient -> dataReceived , apiClient -> dataReceivedLen + size_this_time + 1 );
465468 memcpy (apiClient -> dataReceived + apiClient -> dataReceivedLen , buffer , size_this_time );
466469 apiClient -> dataReceivedLen += size_this_time ;
470+ ((char * )apiClient -> dataReceived )[apiClient -> dataReceivedLen ] = '\0' ; // the space size of (apiClient->dataReceived) = dataReceivedLen + 1
471+ if (apiClient -> data_callback_func ) {
472+ apiClient -> data_callback_func (& apiClient -> dataReceived , & apiClient -> dataReceivedLen );
473+ }
467474 return size_this_time ;
468475}
469476
0 commit comments