Skip to content

Commit 6ec1c00

Browse files
committed
Improved drvector doc, fixed minor comment style errors.
1 parent ceca76e commit 6ec1c00

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

ext/drcontainers/drcontainers.dox

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ The \p drvector DynamoRIO Extension provides a simple resizable array (a vector)
6868
Initialize a vector with drvector_init():
6969
\code
7070
drvector_t vec;
71-
drvector_init(&vec, 10, true, free_callback);
71+
drvector_init(&vec, /*initial_capacity=*/10, /*synch=*/true, free_callback);
7272
\endcode
7373

7474
To provide additional configuration parameters, use drvector_init_ex():
7575
\code
7676
drvector_t vec;
77-
drvector_config_t config = {sizeof(config), true};
78-
drvector_init_ex(&vec, 10, true, free_callback, &config);
77+
drvector_config_t config = {/*size=*/sizeof(config), /*zero_alloc=*/true};
78+
drvector_init_ex(&vec, /*initial_capacity=*/10, /*synch=*/true, free_callback, &config);
7979
\endcode
8080

8181
The \p initial_capacity can be 0, in which case the internal array is lazily allocated
@@ -102,10 +102,11 @@ field of the \p drvector_t structure for better performance.
102102
drvector_set_entry() will automatically resize the vector if the index is beyond
103103
the current capacity. It also updates the number of entries to be \p idx + 1 if the
104104
index is greater than or equal to the current number of entries. Note that entries in
105-
between the last set index and the current index are left uninitialized, hence clearing
106-
or deleting a vector that has a \p free_callback set can be problematic, as the
107-
\p free_callback function will be called on uninitialized entries. It's the user
108-
responsibility to set all entries.
105+
between the last set index and the current index are left uninitialized (unless
106+
#drvector_config_t.zero_alloc is set), hence clearing or deleting a vector that has a
107+
\p free_callback set can be problematic, as the \p free_callback function will be called
108+
on uninitialized entries. It's the user's responsibility to set all entries prior to the
109+
\p free_callback being called.
109110

110111
\subsection sec_drcontainers_vector_synch Synchronization
111112

@@ -150,8 +151,8 @@ void free_data(void *ptr) {
150151
}
151152

152153
drvector_t vec;
153-
drvector_config_t config = {sizeof(config), true};
154-
drvector_init_ex(&vec, 0, false, free_data, &config);
154+
drvector_config_t config = {/*size=*/sizeof(config), /*zero_alloc=*/true};
155+
drvector_init_ex(&vec, /*initial_capacity=*/0, /*synch=*/false, free_data, &config);
155156

156157
int *data = dr_global_alloc(sizeof(int));
157158
*data = 42;

ext/drcontainers/drvector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extern "C" {
5555

5656
/** Configuration parameters for a vector. */
5757
typedef struct _drvector_config_t {
58-
size_t size; /**< The size of the drvector_config_t struct used */
58+
size_t size; /**< The size of the drvector_config_t struct used. */
5959
bool zero_alloc; /**< Set the vector storage to 0 whenever allocated. */
6060
} drvector_config_t;
6161

@@ -71,7 +71,7 @@ typedef struct _drvector_t {
7171
} drvector_t;
7272

7373
/**
74-
* Initializes a drvector with the given parameters
74+
* Initializes a drvector with the given parameters.
7575
*
7676
* @param[out] vec The vector to be initialized.
7777
* @param[in] initial_capacity The initial number of entries allocated
@@ -90,7 +90,7 @@ drvector_init_ex(drvector_t *vec, uint initial_capacity, bool synch,
9090
void (*free_data_func)(void *), drvector_config_t *config);
9191

9292
/**
93-
* Initializes a drvector with the given parameters
93+
* Initializes a drvector with the given parameters.
9494
*
9595
* @param[out] vec The vector to be initialized.
9696
* @param[in] initial_capacity The initial number of entries allocated

0 commit comments

Comments
 (0)