Skip to content

Commit

Permalink
3rdparty/libchdr: Purge now unused patches
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastRar committed Dec 16, 2024
1 parent c8ac652 commit 941f7b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 57 deletions.
4 changes: 0 additions & 4 deletions 3rdparty/libchdr/include/libchdr/chd.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,13 @@ CHD_EXPORT chd_error chd_open(const char *filename, int mode, chd_file *parent,

/* precache underlying file */
CHD_EXPORT chd_error chd_precache(chd_file *chd);
CHD_EXPORT chd_error chd_precache_progress(chd_file* chd, bool(*progress)(size_t pos, size_t total, void* param), void* param);

/* close a CHD file */
CHD_EXPORT void chd_close(chd_file *chd);

/* return the associated core_file */
CHD_EXPORT core_file *chd_core_file(chd_file *chd);

/* return the overall size of a CHD, and any of its parents */
CHD_EXPORT UINT64 chd_get_compressed_size(chd_file* chd);

/* return an error string for the given CHD error */
CHD_EXPORT const char *chd_error_string(chd_error err);

Expand Down
70 changes: 17 additions & 53 deletions 3rdparty/libchdr/src/libchdr_chd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1953,56 +1953,28 @@ CHD_EXPORT chd_error chd_open_core_file(core_file *file, int mode, chd_file *par

CHD_EXPORT chd_error chd_precache(chd_file* chd)
{
return chd_precache_progress(chd, NULL, NULL);
}

CHD_EXPORT chd_error chd_precache_progress(chd_file* chd, bool(*progress)(size_t pos, size_t total, void* param), void* param)
{
#define PRECACHE_CHUNK_SIZE 16 * 1024 * 1024
INT64 count;
UINT64 size;

if (chd->file_cache == NULL)
{
const UINT64 size = core_fsize(chd->file);
if ((INT64)size <= 0)
return CHDERR_INVALID_DATA;

if (size > SIZE_MAX)
if (chd->file_cache == NULL)
{
size = core_fsize(chd->file);
if ((INT64)size <= 0)
return CHDERR_INVALID_DATA;
chd->file_cache = malloc(size);
if (chd->file_cache == NULL)
return CHDERR_OUT_OF_MEMORY;

chd->file_cache = malloc(size);
if (chd->file_cache == NULL)
return CHDERR_OUT_OF_MEMORY;
core_fseek(chd->file, 0, SEEK_SET);

UINT64 done = 0;
while (done < size)
core_fseek(chd->file, 0, SEEK_SET);
count = core_fread(chd->file, chd->file_cache, size);
if (count != size)
{
UINT64 req_count = size - done;
if (req_count > PRECACHE_CHUNK_SIZE)
req_count = PRECACHE_CHUNK_SIZE;

size_t count = core_fread(chd->file, chd->file_cache + (size_t)done, (size_t)req_count);
if (count != (size_t)req_count)
{
free(chd->file_cache);
chd->file_cache = NULL;
return CHDERR_READ_ERROR;
}

done += req_count;
if (progress != NULL)
{
if (!progress(done, size, param))
{
free(chd->file_cache);
chd->file_cache = NULL;
return CHDERR_CANCELLED;
}
}
free(chd->file_cache);
chd->file_cache = NULL;
return CHDERR_READ_ERROR;
}
}
}

return CHDERR_NONE;
return CHDERR_NONE;
}

/*-------------------------------------------------
Expand Down Expand Up @@ -2169,14 +2141,6 @@ CHD_EXPORT core_file *chd_core_file(chd_file *chd)
return chd->file;
}

CHD_EXPORT UINT64 chd_get_compressed_size(chd_file *chd)
{
UINT64 size = chd->file->fsize(chd->file);
if (chd->parent)
size += chd_get_compressed_size(chd->parent);
return size;
}

/*-------------------------------------------------
chd_error_string - return an error string for
the given CHD error
Expand Down

0 comments on commit 941f7b2

Please sign in to comment.