Skip to content

Commit

Permalink
drop deprecated bzero function
Browse files Browse the repository at this point in the history
  • Loading branch information
ESResearchDepartment committed Jul 26, 2024
1 parent f8b3184 commit d2d0c11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ AC_TYPE_UINT32_T
AC_TYPE_UINT64_T

# Checks for library functions.
AC_CHECK_FUNCS([bzero strdup])
AC_CHECK_FUNCS([strdup])

AC_CONFIG_FILES([Makefile
include/Makefile
Expand Down
20 changes: 9 additions & 11 deletions libfragmentzip/libfragmentzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//


#define _POSIX_C_SOURCE 200809L
#define _FILE_OFFSET_BITS 64

#include <libgeneral/macros.h>
Expand All @@ -27,9 +28,6 @@
#define _impl_CASSERT_LINE(predicate, line, file) \
typedef char _impl_PASTE(assertion_failed_##file##_,line)[2*!!(predicate)-1];

#ifndef HAVE_BZERO
#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
#endif

typedef struct{
char *buf;
Expand Down Expand Up @@ -179,10 +177,10 @@ fragmentzip_t *fragmentzip_open_extended(const char *url, CURL *mcurl){
CURLcode cc = CURLE_OK;

cassure(dbuf = malloc(sizeof(t_downloadBuffer)));
bzero(dbuf, sizeof(t_downloadBuffer));
memset(dbuf, 0, sizeof(t_downloadBuffer));

cassure(info = (fragmentzip_t*)malloc(sizeof(fragmentzip_t)));
bzero(info,sizeof(fragmentzip_t));
memset(info, 0, sizeof(fragmentzip_t));

cassure(info->url = strdup(url));
cassure(info->mcurl = mcurl);
Expand Down Expand Up @@ -246,7 +244,7 @@ fragmentzip_t *fragmentzip_open_extended(const char *url, CURL *mcurl){

if (info->isZIP64) {
//get fragmentzip64_end_of_cd_locator
bzero(downloadRange, sizeof(downloadRange));
memset(downloadRange, 0, sizeof(downloadRange));
snprintf(downloadRange, sizeof(downloadRange), "%llu-%llu",info->length - sizeof(fragmentzip_end_of_cd) - sizeof(fragmentzip64_end_of_cd_locator), info->length - sizeof(fragmentzip_end_of_cd));
dbuf->size_buf = info->internal.cd_end->cd_size + sizeof(fragmentzip64_end_of_cd_locator);

Expand All @@ -267,7 +265,7 @@ fragmentzip_t *fragmentzip_open_extended(const char *url, CURL *mcurl){
fixEndian_end_of_cd_locator64(info->internal.cd64_end_locator);

//get fragmentzip64_end_of_cd
bzero(downloadRange, sizeof(downloadRange));
memset(downloadRange, 0, sizeof(downloadRange));
snprintf(downloadRange, sizeof(downloadRange), "%llu-%llu",info->internal.cd64_end_locator->end_of_cd_record_offset, info->internal.cd64_end_locator->end_of_cd_record_offset+sizeof(fragmentzip64_end_of_cd)-1);

dbuf->size_buf = sizeof(fragmentzip64_end_of_cd);
Expand All @@ -289,12 +287,12 @@ fragmentzip_t *fragmentzip_open_extended(const char *url, CURL *mcurl){
info->internal.cd64_end = (fragmentzip64_end_of_cd*)dbuf->buf; dbuf->buf = NULL;
fixEndian_end_of_cd64(info->internal.cd64_end);

bzero(downloadRange, sizeof(downloadRange));
memset(downloadRange, 0, sizeof(downloadRange));
dbuf->size_buf = info->internal.cd64_end->cd_size + sizeof(fragmentzip64_end_of_cd);
snprintf(downloadRange, sizeof(downloadRange), "%llu-%llu",info->internal.cd64_end->cd_start_offset, info->internal.cd64_end->cd_start_offset+dbuf->size_buf-1);

}else{
bzero(downloadRange, sizeof(downloadRange));
memset(downloadRange, 0, sizeof(downloadRange));
dbuf->size_buf = info->internal.cd_end->cd_size + sizeof(fragmentzip_end_of_cd);
snprintf(downloadRange, sizeof(downloadRange), "%u-%lu",info->internal.cd_end->cd_start_offset, info->internal.cd_end->cd_start_offset+dbuf->size_buf-1);
}
Expand Down Expand Up @@ -450,7 +448,7 @@ int fragmentzip_download_to_memory(fragmentzip_t *info, const char *remotepath,
cassure(!fragmentzip_getFileInfo(rfile, &uncompressedSize, &compressedSize, &headerOffset, NULL));

cassure(compressed = (t_downloadBuffer*)malloc(sizeof(t_downloadBuffer)));
bzero(compressed, sizeof(t_downloadBuffer));
memset(compressed, 0, sizeof(t_downloadBuffer));

compressed->callback = callback;

Expand All @@ -477,7 +475,7 @@ int fragmentzip_download_to_memory(fragmentzip_t *info, const char *remotepath,
compressed->size_downloaded = 0;
cassure(compressed->buf = malloc(compressed->size_buf = compressedSize));

bzero(downloadRange,sizeof(downloadRange));
memset(downloadRange, 0, sizeof(downloadRange));

uint64_t start = headerOffset + sizeof(fragentzip_local_file) + lfile->len_filename + lfile->len_extra_field;
snprintf(downloadRange, sizeof(downloadRange), "%llu-%llu",start,start+compressed->size_buf-1);
Expand Down

0 comments on commit d2d0c11

Please sign in to comment.