Commit 704e5537 authored by Lubomir Bulej's avatar Lubomir Bulej

Add a static function to load a jar file

Strictly check for errors to ensure that instrumentation jars
can be loaded a passed to the server.
parent f7c43471
......@@ -73,6 +73,26 @@ get_filesize(const char * filename) {
return (buffer.st_size);
static void
__load_file (const char * name, void ** buffer, size_t * size) {
FILE * file = fopen (name, "r");
check_std_error (file == NULL, "failed to open %s", name);
size_t file_size = (size_t) get_filesize (name);
void * file_data = malloc (file_size);
check_std_error (file_data == NULL, "failed to allocate buffer for %s", name);
size_t bytes_read = fread (file_data, 1, file_size, file);
check_std_error (bytes_read != file_size, "failed to load %s", name);
fclose (file);
*buffer = file_data;
*size = file_size;
* Load the files to the buffers.
* @return
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment