Skip to content

Commit

Permalink
change _SUNMemory and _SUNProfiler to SUNMemory_ and SUNProfiler_
Browse files Browse the repository at this point in the history
  • Loading branch information
balos1 committed Dec 3, 2023
1 parent cee26d5 commit 8462a68
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions doc/shared/sunmemory/SUNMemory_Description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ This API consists of three new SUNDIALS types: :c:type:`SUNMemoryType`,
:c:type:`SUNMemory`, and :c:type:`SUNMemoryHelper`:


.. c:type:: struct _SUNMemory *SUNMemory
.. c:type:: struct SUNMemory_ *SUNMemory
The ``SUNMemory`` type is a pointer a structure containing a pointer to
actual data (``ptr``), the data memory type, and a flag indicating ownership
of that data pointer. This structure is defined as

.. code-block:: c
struct _SUNMemory
struct SUNMemory_
{
void* ptr;
SUNMemoryType type;
Expand All @@ -53,31 +53,31 @@ This API consists of three new SUNDIALS types: :c:type:`SUNMemoryType`,
} SUNMemoryType;
.. c:type:: struct _SUNMemoryHelper *SUNMemoryHelper
.. c:type:: struct SUNMemoryHelper_ *SUNMemoryHelper
The ``SUNMemoryHelper`` type is a pointer to a structure containing a pointer
to the implementation-specific member data (``content``) and a virtual method
table of member functions (``ops``). This strucutre is defined as

.. code-block:: c
struct _SUNMemoryHelper
struct SUNMemoryHelper_
{
void* content;
SUNMemoryHelper_Ops ops;
SUNContext sunctx;
};
.. c:type:: struct _SUNMemoryHelper_Ops *SUNMemoryHelper_Ops
.. c:type:: struct SUNMemoryHelper_Ops_ *SUNMemoryHelper_Ops
The ``SUNMemoryHelper_Ops`` type is defined as a pointer to the structure
containing the function pointers to the member function implementations. This
structure is define as

.. code-block:: c
struct _SUNMemoryHelper_Ops
struct SUNMemoryHelper_Ops_
{
/* operations that implementations are required to provide */
int (*alloc)(SUNMemoryHelper, SUNMemory* memptr size_t mem_size,
Expand Down
12 changes: 6 additions & 6 deletions include/sundials/sundials_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ typedef enum
* and its ownership.
*/

typedef struct _SUNMemory* SUNMemory;
typedef struct SUNMemory_* SUNMemory;

struct _SUNMemory
struct SUNMemory_
{
void* ptr;
SUNMemoryType type;
Expand All @@ -57,17 +57,17 @@ SUNDIALS_EXPORT SUNMemory SUNMemoryNewEmpty();
* and copy SUNMemory.
*/

typedef struct _SUNMemoryHelper_Ops* SUNMemoryHelper_Ops;
typedef struct _SUNMemoryHelper* SUNMemoryHelper;
typedef struct SUNMemoryHelper_Ops_* SUNMemoryHelper_Ops;
typedef struct SUNMemoryHelper_* SUNMemoryHelper;

struct _SUNMemoryHelper
struct SUNMemoryHelper_
{
void* content;
SUNMemoryHelper_Ops ops;
SUNContext sunctx;
};

struct _SUNMemoryHelper_Ops
struct SUNMemoryHelper_Ops_
{
/* operations that implementations are required to provide */
SUNErrCode (*alloc)(SUNMemoryHelper, SUNMemory* memptr, size_t mem_size,
Expand Down
2 changes: 1 addition & 1 deletion include/sundials/sundials_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace sundials {
namespace impl {
using BaseMemoryHelper = BaseObject<_SUNMemoryHelper, _SUNMemoryHelper_Ops>;
using BaseMemoryHelper = BaseObject<SUNMemoryHelper_, SUNMemoryHelper_Ops_>;
} // namespace impl

namespace experimental {
Expand Down
10 changes: 5 additions & 5 deletions src/sundials/sundials_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SUNMemory SUNMemoryNewEmpty()
{
SUNMemory mem = NULL;

mem = (SUNMemory)malloc(sizeof(struct _SUNMemory));
mem = (SUNMemory)malloc(sizeof(struct SUNMemory_));

mem->bytes = 0;

Expand All @@ -47,14 +47,14 @@ SUNMemoryHelper SUNMemoryHelper_NewEmpty(SUNContext sunctx)
SUNFunctionBegin(sunctx);
SUNMemoryHelper helper = NULL;

helper = (SUNMemoryHelper)malloc(sizeof(struct _SUNMemoryHelper));
helper = (SUNMemoryHelper)malloc(sizeof(struct SUNMemoryHelper_));
SUNAssert(helper, SUN_ERR_MALLOC_FAIL);

helper->ops = (SUNMemoryHelper_Ops)malloc(sizeof(struct _SUNMemoryHelper_Ops));
helper->ops = (SUNMemoryHelper_Ops)malloc(sizeof(struct SUNMemoryHelper_Ops_));
SUNAssert(helper->ops, SUN_ERR_MALLOC_FAIL);

/* Set all ops to NULL */
memset(helper->ops, 0, sizeof(struct _SUNMemoryHelper_Ops));
memset(helper->ops, 0, sizeof(struct SUNMemoryHelper_Ops_));
helper->content = NULL;
helper->sunctx = sunctx;

Expand All @@ -63,7 +63,7 @@ SUNMemoryHelper SUNMemoryHelper_NewEmpty(SUNContext sunctx)

SUNErrCode SUNMemoryHelper_CopyOps(SUNMemoryHelper src, SUNMemoryHelper dst)
{
memcpy(dst->ops, src->ops, sizeof(struct _SUNMemoryHelper_Ops));
memcpy(dst->ops, src->ops, sizeof(struct SUNMemoryHelper_Ops_));
return SUN_SUCCESS;
}

Expand Down

0 comments on commit 8462a68

Please sign in to comment.