From 96a5585d65d3b66d66f3da6e48767c0bacfa35f0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 13 Sep 2020 17:12:11 -0400 Subject: [PATCH] use more const char pointers --- src/atom.cpp | 2 +- src/atom.h | 2 +- src/library.cpp | 15 ++++++++------- src/library.h | 12 ++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 49ff262764..f28237cf74 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -2508,7 +2508,7 @@ length of the data area, and a short description. Typically the name of the pointer variable returned * \return pointer to the requested data cast to ``void *`` or NULL */ -void *Atom::extract(char *name) +void *Atom::extract(const char *name) { // -------------------------------------------------------------------- // 4th customization section: customize by adding new variable name diff --git a/src/atom.h b/src/atom.h index 21b9c06f8c..728d420596 100644 --- a/src/atom.h +++ b/src/atom.h @@ -331,7 +331,7 @@ class Atom : protected Pointers { virtual void sync_modify(ExecutionSpace, unsigned int, unsigned int) {} - void *extract(char *); + void *extract(const char *); inline int* get_map_array() {return map_array;}; inline int get_map_size() {return map_tag_max+1;}; diff --git a/src/library.cpp b/src/library.cpp index 4f02e95621..5773a677c1 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -69,7 +69,7 @@ using namespace LAMMPS_NS; #ifdef LAMMPS_EXCEPTIONS #define BEGIN_CAPTURE \ - Error * error = lmp->error; \ + Error *error = lmp->error; \ try #define END_CAPTURE \ @@ -807,7 +807,7 @@ recognized, the function returns -1. Please also see :cpp:func:`lammps_extract_ * \param keyword string with the name of the thermo keyword * \return value of the queried setting or -1 if unknown */ -int lammps_extract_setting(void * handle, char *keyword) +int lammps_extract_setting(void *handle, const char *keyword) { LAMMPS *lmp = (LAMMPS *) handle; @@ -1073,7 +1073,7 @@ to be either an ``int`` or an ``int64_t``. This is selected at * \return pointer (cast to ``void *``) to the location of the requested property. NULL if name is not known. */ -void *lammps_extract_global(void *handle, char *name) +void *lammps_extract_global(void *handle, const char *name) { LAMMPS *lmp = (LAMMPS *) handle; @@ -1165,7 +1165,7 @@ of the :cpp:func:`Atom::extract() ` function. * \return pointer (cast to ``void *``) to the location of the * requested data or ``NULL`` if not found. */ -void *lammps_extract_atom(void *handle, char *name) +void *lammps_extract_atom(void *handle, const char *name) { LAMMPS *lmp = (LAMMPS *) handle; return lmp->atom->extract(name); @@ -3792,7 +3792,7 @@ Valid categories are: *atom*\ , *integrate*\ , *minimize*\ , * \param name name of the style * \return 1 if included, 0 if not. */ -int lammps_has_style(void * handle, char * category, char * name) { +int lammps_has_style(void *handle, const char *category, const char *name) { LAMMPS *lmp = (LAMMPS *) handle; Info info(lmp); return info.has_style(category, name) ? 0 : 1; @@ -3813,7 +3813,7 @@ categories. * \param category category of styles * \return number of styles in category */ -int lammps_style_count(void * handle, char * category) { +int lammps_style_count(void *handle, const char *category) { LAMMPS *lmp = (LAMMPS *) handle; Info info(lmp); return info.get_available_styles(category).size(); @@ -3839,7 +3839,8 @@ Please see :cpp:func:`lammps_has_style` for a list of valid categories. * \param buf_size size of the provided string buffer * \return 1 if successful, otherwise 0 */ -int lammps_style_name(void* handle, char * category, int idx, char * buffer, int buf_size) { +int lammps_style_name(void *handle, const char *category, int idx, + const char *buffer, int buf_size) { LAMMPS *lmp = (LAMMPS *) handle; Info info(lmp); auto styles = info.get_available_styles(category); diff --git a/src/library.h b/src/library.h index ebbe1464df..1147cc4d9a 100644 --- a/src/library.h +++ b/src/library.h @@ -108,9 +108,9 @@ void lammps_extract_box(void *handle, double *boxlo, double *boxhi, void lammps_reset_box(void *handle, double *boxlo, double *boxhi, double xy, double yz, double xz); -int lammps_extract_setting(void *handle, char *keyword); -void *lammps_extract_global(void *handle, char *name); -void *lammps_extract_atom(void *handle, char *name); +int lammps_extract_setting(void *handle, const char *keyword); +void *lammps_extract_global(void *handle, const char *name); +void *lammps_extract_atom(void *handle, const char *name); #if !defined(LAMMPS_BIGBIG) int lammps_create_atoms(void *handle, int n, int *id, int *type, @@ -161,9 +161,9 @@ int lammps_config_has_jpeg_support(); int lammps_config_has_ffmpeg_support(); int lammps_config_has_exceptions(); -int lammps_has_style(void *, char *, char *); -int lammps_style_count(void *, char *); -int lammps_style_name(void *, char *, int, char *, int); +int lammps_has_style(void *, const char *, const char *); +int lammps_style_count(void *, const char *); +int lammps_style_name(void *, const char *, int, const char *, int); /* ---------------------------------------------------------------------- * Library functions for accessing neighbor lists