Skip to content

Commit d144434

Browse files
committed
Add function to free an ndarray's allocated memory
1 parent ba489df commit d144434

File tree

2 files changed

+12
-0
lines changed
  • lib/node_modules/@stdlib/ndarray/ctor

2 files changed

+12
-0
lines changed

lib/node_modules/@stdlib/ndarray/ctor/include/stdlib/ndarray/ctor.h

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
*/
4141
struct ndarray * stdlib_ndarray_allocate( enum STDLIB_NDARRAY_DTYPE dtype, uint8_t *data, int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, enum STDLIB_NDARRAY_ORDER order, enum STDLIB_NDARRAY_INDEX_MODE imode, int64_t nsubmodes, enum STDLIB_NDARRAY_INDEX_MODE *submodes );
4242

43+
/**
44+
* Frees an ndarray's allocated memory.
45+
*/
46+
void stdlib_ndarray_free( struct ndarray *arr );
47+
4348
/**
4449
* Returns a pointer to an ndarray's underlying byte array.
4550
*/

lib/node_modules/@stdlib/ndarray/ctor/src/main.c

+7
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ struct ndarray * stdlib_ndarray_allocate( enum STDLIB_NDARRAY_DTYPE dtype, uint8
123123
return arr;
124124
}
125125

126+
/**
127+
* Frees an ndarray's allocated memory.
128+
*/
129+
void stdlib_ndarray_free( struct ndarray *arr ) {
130+
free( arr );
131+
}
132+
126133
/**
127134
* Returns a pointer to an ndarray's underlying byte array.
128135
*

0 commit comments

Comments
 (0)