mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Check if array destructor is NULL
This commit is contained in:
parent
93d19a2e7d
commit
5a12d1e372
@ -27,9 +27,10 @@ void array_alloc(struct array **a, array_dtor dtor)
|
||||
|
||||
void array_free(struct array *array)
|
||||
{
|
||||
int i=0;
|
||||
for (i=0; i<array->index; i++){
|
||||
array->dtor(array->data[i]);
|
||||
if (array->dtor != NULL) {
|
||||
for (int i=0; i<array->index; i++){
|
||||
array->dtor(array->data[i]);
|
||||
}
|
||||
}
|
||||
xfree(array->data);
|
||||
xfree(array);
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#ifndef __ARRAY_H__
|
||||
#define __ARRAY_H__
|
||||
struct array;
|
||||
typedef struct array array_t;
|
||||
typedef void (*array_dtor)(void*);
|
||||
typedef int (*array_comp)(const void*, const void*);
|
||||
void array_alloc(struct array **array, array_dtor dtor);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user