Skip to content

Commit

Permalink
replacing sprintf #6
Browse files Browse the repository at this point in the history
  • Loading branch information
dcooley committed Jul 13, 2023
1 parent 16a0419 commit 6aeb0ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions inst/include/h3libapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ inline H3Error stringToH3( const char *str, H3Index *out ) {
return fun( str, out );
}

inline H3Error h3ToString( H3Index h, char *str, size_t sz ) {
H3Error (*fun)( H3Index, char*, size_t ) =
( H3Error (*)( H3Index, char*, size_t )) R_GetCCallable("h3lib","h3ToString");
return fun( h, str, sz );
}
// inline H3Error h3ToString( H3Index h, char *str, size_t sz ) {
// H3Error (*fun)( H3Index, char*, size_t ) =
// ( H3Error (*)( H3Index, char*, size_t )) R_GetCCallable("h3lib","h3ToString");
// return fun( h, str, sz );
// }

inline int isValidCell( H3Index h ) {
int (*fun)( H3Index ) =
Expand Down
5 changes: 3 additions & 2 deletions src/h3Index.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ H3Error H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz) {
// Buffer is potentially not large enough.
return E_MEMORY_BOUNDS;
}
sprintf(str, "%" PRIx64, h);
return E_SUCCESS;
//sprintf(str, "%" PRIx64, h);
//return E_SUCCESS;
return E_FAILED;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/h3api.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ DECLSPEC H3Error H3_EXPORT(stringToH3)(const char *str, H3Index *out);
* @{
*/
/** @brief converts an H3Index to a canonical string */
DECLSPEC H3Error H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz);
//DECLSPEC H3Error H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz);
/** @} */

/** @defgroup isValidCell isValidCell
Expand Down
2 changes: 1 addition & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void attribute_visible R_init_h3lib(DllInfo *info)
R_RegisterCCallable("h3lib", "getResolution", (DL_FUNC) &getResolution);
R_RegisterCCallable("h3lib", "getBaseCellNumber", (DL_FUNC) &getBaseCellNumber);
R_RegisterCCallable("h3lib", "stringToH3", (DL_FUNC) &stringToH3);
R_RegisterCCallable("h3lib", "h3ToString", (DL_FUNC) &h3ToString);
//R_RegisterCCallable("h3lib", "h3ToString", (DL_FUNC) &h3ToString);
R_RegisterCCallable("h3lib", "isValidCell", (DL_FUNC) &isValidCell);
R_RegisterCCallable("h3lib", "cellToParent", (DL_FUNC) &cellToParent);
R_RegisterCCallable("h3lib", "cellToChildrenSize", (DL_FUNC) &cellToChildrenSize);
Expand Down

0 comments on commit 6aeb0ca

Please sign in to comment.