Source
874
874
875
875
/* Return a handle for the function H5PLget_plugin_info in the dynamic library.
876
876
* The plugin library is suppose to define this function.
877
877
*/
878
878
if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_info"))) {
879
879
if(H5PL__close(handle) < 0)
880
880
HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
881
881
} /* end if */
882
882
else {
883
883
const H5Z_class2_t *plugin_info;
884
-
H5Z_class2_t *plugin_copy = NULL;
885
884
886
885
/* Invoke H5PLget_plugin_info to verify this is the right library we are looking for.
887
886
* Move on if it isn't.
888
887
*/
889
888
if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)())) {
890
889
if(H5PL__close(handle) < 0)
891
890
HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
892
891
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info")
893
892
} /* end if */
894
893
904
903
905
904
H5PL_table_g = table;
906
905
H5PL_table_alloc_g = n;
907
906
} /* end if */
908
907
909
908
(H5PL_table_g[H5PL_table_used_g]).handle = handle;
910
909
(H5PL_table_g[H5PL_table_used_g]).pl_type = pl_type;
911
910
(H5PL_table_g[H5PL_table_used_g]).pl_id = plugin_info->id;
912
911
H5PL_table_used_g++;
913
912
914
-
/* allocate local copy of plugin info */
915
-
if (NULL == (plugin_copy = (H5Z_class2_t *)H5MM_calloc(sizeof(H5Z_class2_t))))
916
-
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin info")
917
913
/* Set the plugin info to return */
918
-
*pl_info = (const void *)plugin_copy;
919
-
920
-
plugin_copy->version = plugin_info->version;
921
-
plugin_copy->id = plugin_info->id;
922
-
plugin_copy->encoder_present = plugin_info->encoder_present;
923
-
plugin_copy->decoder_present = plugin_info->decoder_present;
924
-
plugin_copy->can_apply = plugin_info->can_apply;
925
-
plugin_copy->set_local = plugin_info->set_local;
926
-
plugin_copy->filter = plugin_info->filter;
927
-
/* copy the user's string into the property */
928
-
if(NULL == (plugin_copy->name = (char *)H5MM_xstrdup(plugin_info->name)))
929
-
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "can't allocate memory for plugin info name")
914
+
*pl_info = (const void *)plugin_info;
930
915
931
916
/* Indicate success */
932
917
ret_value = TRUE;
933
918
} /* end if */
934
919
else
935
920
if(H5PL__close(handle) < 0)
936
921
HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
937
922
} /* end if */
938
923
} /* end else */
939
924
940
925
done:
941
-
/* unallocate local copy of plugin info on failure */
942
-
if (FAIL == ret_value && *pl_info) {
943
-
*pl_info = (H5Z_class2_t *)H5MM_xfree(*pl_info);
944
-
}
945
926
FUNC_LEAVE_NOAPI(ret_value)
946
927
} /* end H5PL__open() */
947
928
948
929
•
949
930
/*-------------------------------------------------------------------------
950
931
* Function: H5PL__search_table
951
932
*
952
933
* Purpose: Search in the list of already opened dynamic libraries
953
934
* to see if the one we are looking for is already opened.
954
935
*
969
950
FUNC_ENTER_STATIC
970
951
971
952
/* Search in the table of already opened dynamic libraries */
972
953
if(H5PL_table_used_g > 0) {
973
954
size_t i;
974
955
975
956
for(i = 0; i < H5PL_table_used_g; i++) {
976
957
if((plugin_type == (H5PL_table_g[i]).pl_type) && (type_id == (H5PL_table_g[i]).pl_id)) {
977
958
H5PL_get_plugin_info_t get_plugin_info;
978
959
const H5Z_class2_t *plugin_info;
979
-
H5Z_class2_t *plugin_copy = NULL;
980
960
981
961
if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_table_g[i]).handle, "H5PLget_plugin_info")))
982
962
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info")
983
963
984
964
if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)()))
985
965
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info")
986
966
987
-
if (NULL == (plugin_copy = (H5Z_class2_t *)H5MM_calloc(sizeof(H5Z_class2_t))))
988
-
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin info")
989
-
/* Set the plugin info to return */
990
-
*info = (const void *)plugin_copy;
991
-
992
-
plugin_copy->version = plugin_info->version;
993
-
plugin_copy->id = plugin_info->id;
994
-
plugin_copy->encoder_present = plugin_info->encoder_present;
995
-
plugin_copy->decoder_present = plugin_info->decoder_present;
996
-
plugin_copy->can_apply = plugin_info->can_apply;
997
-
plugin_copy->set_local = plugin_info->set_local;
998
-
plugin_copy->filter = plugin_info->filter;
999
-
/* copy the user's string into the property */
1000
-
if(NULL == (plugin_copy->name = (char *)H5MM_xstrdup(plugin_info->name)))
1001
-
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "can't allocate memory for plugin info name")
1002
-
967
+
*info = plugin_info;
1003
968
HGOTO_DONE(TRUE)
1004
969
} /* end if */
1005
970
} /* end for */
1006
971
} /* end if */
1007
972
1008
973
done:
1009
-
/* unallocate local copy of plugin info on failure */
1010
-
if (FAIL == ret_value && *info) {
1011
-
*info = (H5Z_class2_t *)H5MM_xfree(*info);
1012
-
}
1013
974
FUNC_LEAVE_NOAPI(ret_value)
1014
975
} /* end H5PL__search_table() */
1015
976
1016
977
•
1017
978
/*-------------------------------------------------------------------------
1018
979
* Function: H5PL__close
1019
980
*
1020
981
* Purpose: Closes the handle for dynamic library
1021
982
*
1022
983
* Return: Non-negative on success/Negative on failure