Minor fixes all around
Changed some input parameter names Updated TODO Changed how hashtables initialization works. Now the given initial capacity will be guaranteed to be reached before the hashtable rehashes (load is now considered in the calculation).
This commit is contained in:
1 parent
b6cbadd8e2
commit
b0a2e42cfe
8 files changed
+55
-58
No files matched your search
+12
-12
@@ -136,15 +136,15 @@ The iterator is a simple structure that is capable of going back and forwards. A
|
|||||||
|
|
||||||
## [<span id="list_new"> \_new() </span>](#list_function_index)
|
## [<span id="list_new"> \_new() </span>](#list_function_index)
|
||||||
|
|
||||||
Allocates and returns a new list with an internal capacity of `size`. If allocation fails, `NULL` is returned.
|
Allocates and returns a new list with an internal capacity of the specified value. If allocation fails, `NULL` is returned.
|
||||||
|
|
||||||
#### Declaration
|
#### Declaration
|
||||||
|
|
||||||
> `FMOD SNAME *PFX##_new(size_t size);`
|
> `FMOD SNAME *PFX##_new(size_t capacity);`
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
1. `size_t size` - The initial capacity for the list.
|
1. `size_t capacity` - The initial capacity for the list.
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -1028,15 +1028,15 @@ A Stack is used in algorithms like backtracking, depth-first search, expression
|
|||||||
|
|
||||||
## [<span id="stack_new"> \_new() </span>](#stack_function_index)
|
## [<span id="stack_new"> \_new() </span>](#stack_function_index)
|
||||||
|
|
||||||
Allocates and returns a new stack with an internal capacity of `size`. If allocation fails, `NULL` is returned.
|
Allocates and returns a new stack with an internal capacity of the specified value. If allocation fails, `NULL` is returned.
|
||||||
|
|
||||||
#### Declaration
|
#### Declaration
|
||||||
|
|
||||||
> `FMOD SNAME *PFX##_new(size_t size);`
|
> `FMOD SNAME *PFX##_new(size_t capacity);`
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
1. `size_t size` - The initial capacity for the stack.
|
1. `size_t capacity` - The initial capacity for the stack.
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -1545,15 +1545,15 @@ The queue is used in many applications where a resource is shared among multiple
|
|||||||
|
|
||||||
## [<span id="queue_new"> \_new() </span>](#queue_function_index)
|
## [<span id="queue_new"> \_new() </span>](#queue_function_index)
|
||||||
|
|
||||||
Allocates and returns a new queue with an internal capacity of `size`. If allocation fails, `NULL` is returned.
|
Allocates and returns a new queue with an internal capacity of the specified value. If allocation fails, `NULL` is returned.
|
||||||
|
|
||||||
#### Declaration
|
#### Declaration
|
||||||
|
|
||||||
> `FMOD SNAME *PFX##_new(size_t size);`
|
> `FMOD SNAME *PFX##_new(size_t capacity);`
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
1. `size_t size` - The initial capacity for the queue.
|
1. `size_t capacity` - The initial capacity for the queue.
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -2062,15 +2062,15 @@ A double-ended queue backed by a circular buffer. Elements can be added and remo
|
|||||||
|
|
||||||
## [<span id="deque_new"> \_new() </span>](#deque_function_index)
|
## [<span id="deque_new"> \_new() </span>](#deque_function_index)
|
||||||
|
|
||||||
Allocates and returns a new deque with an internal capacity of `size`. If allocation fails, `NULL` is returned.
|
Allocates and returns a new deque with an internal capacity of the specified value. If allocation fails, `NULL` is returned.
|
||||||
|
|
||||||
#### Declaration
|
#### Declaration
|
||||||
|
|
||||||
> `FMOD SNAME *PFX##_new(size_t size);`
|
> `FMOD SNAME *PFX##_new(size_t capacity);`
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
1. `size_t size` - The initial capacity for the deque.
|
1. `size_t capacity` - The initial capacity for the deque.
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
|
|||||||
@@ -25,27 +25,24 @@ Before 2.0
|
|||||||
OK - Allow for struct to be a possible data type (instead of just pointer to struct)
|
OK - Allow for struct to be a possible data type (instead of just pointer to struct)
|
||||||
OK - Set functions: is_subset, is_proper_subset, is_superset, is_proper_superset, is_disjointset
|
OK - Set functions: is_subset, is_proper_subset, is_superset, is_proper_superset, is_disjointset
|
||||||
Iterator move and move_to
|
Iterator move and move_to
|
||||||
from_array - Creates a collection with all the elements in a specified array
|
|
||||||
to_array - Creates an array with all the elements inside the collection
|
|
||||||
|
|
||||||
1.6
|
1.6
|
||||||
|
from_array - Creates a collection with all the elements in a specified array
|
||||||
|
to_array - Creates an array with all the elements inside the collection
|
||||||
LinkedList - Insert/Remove/Append/Prepend/Extract
|
LinkedList - Insert/Remove/Append/Prepend/Extract
|
||||||
Resize buffer function
|
Resize buffer function
|
||||||
Add dispose method to each collection in order to automatically free its data
|
Add dispose method to each collection in order to automatically free its data
|
||||||
|
Add copy functions (copy of a collection)
|
||||||
|
|
||||||
2.0
|
2.0
|
||||||
Add multiset, multimap and new heap implementation
|
Add new heap collection implementation
|
||||||
|
Add stack based collections
|
||||||
|
|
||||||
2.1
|
2.1
|
||||||
Adapt multiset, multimap and new heap implementation to the current standards
|
Add variadic macros (generate only the necessary functions)
|
||||||
|
|
||||||
2.2
|
2.2
|
||||||
Add serialization functions
|
Add serialization functions
|
||||||
Header:
|
|
||||||
%d - Type specifier (LIST = 0, DEQUE = 1, STACK = 2, etc) for quick check
|
|
||||||
%llu - How many elements there are
|
|
||||||
%d - If data varies in size
|
|
||||||
%llu - Data size
|
|
||||||
|
|
||||||
2.3
|
2.3
|
||||||
Iterator functions (functions that operate relative to iterators position) like add or remove ranges
|
Iterator functions (functions that operate relative to iterators position) like add or remove ranges
|
||||||
|
|||||||
+6
-6
@@ -80,7 +80,7 @@
|
|||||||
\
|
\
|
||||||
/* Collection Functions */ \
|
/* Collection Functions */ \
|
||||||
/* Collection Allocation and Deallocation */ \
|
/* Collection Allocation and Deallocation */ \
|
||||||
FMOD SNAME *PFX##_new(size_t size); \
|
FMOD SNAME *PFX##_new(size_t capacity); \
|
||||||
FMOD void PFX##_clear(SNAME *_deque_); \
|
FMOD void PFX##_clear(SNAME *_deque_); \
|
||||||
FMOD void PFX##_free(SNAME *_deque_); \
|
FMOD void PFX##_free(SNAME *_deque_); \
|
||||||
/* Collection Input and Output */ \
|
/* Collection Input and Output */ \
|
||||||
@@ -140,9 +140,9 @@
|
|||||||
static SNAME##_iter PFX##_impl_it_start(SNAME *_deque_); \
|
static SNAME##_iter PFX##_impl_it_start(SNAME *_deque_); \
|
||||||
static SNAME##_iter PFX##_impl_it_end(SNAME *_deque_); \
|
static SNAME##_iter PFX##_impl_it_end(SNAME *_deque_); \
|
||||||
\
|
\
|
||||||
FMOD SNAME *PFX##_new(size_t size) \
|
FMOD SNAME *PFX##_new(size_t capacity) \
|
||||||
{ \
|
{ \
|
||||||
if (size < 1) \
|
if (capacity < 1) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
SNAME *_deque_ = malloc(sizeof(SNAME)); \
|
SNAME *_deque_ = malloc(sizeof(SNAME)); \
|
||||||
@@ -150,7 +150,7 @@
|
|||||||
if (!_deque_) \
|
if (!_deque_) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
_deque_->buffer = malloc(sizeof(V) * size); \
|
_deque_->buffer = malloc(sizeof(V) * capacity); \
|
||||||
\
|
\
|
||||||
if (!_deque_->buffer) \
|
if (!_deque_->buffer) \
|
||||||
{ \
|
{ \
|
||||||
@@ -158,9 +158,9 @@
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
memset(_deque_->buffer, 0, sizeof(V) * size); \
|
memset(_deque_->buffer, 0, sizeof(V) * capacity); \
|
||||||
\
|
\
|
||||||
_deque_->capacity = size; \
|
_deque_->capacity = capacity; \
|
||||||
_deque_->count = 0; \
|
_deque_->count = 0; \
|
||||||
_deque_->front = 0; \
|
_deque_->front = 0; \
|
||||||
_deque_->back = 0; \
|
_deque_->back = 0; \
|
||||||
|
|||||||
+7
-7
@@ -150,7 +150,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531,
|
|||||||
\
|
\
|
||||||
/* Collection Functions */ \
|
/* Collection Functions */ \
|
||||||
/* Collection Allocation and Deallocation */ \
|
/* Collection Allocation and Deallocation */ \
|
||||||
FMOD SNAME *PFX##_new(size_t size, double load, int (*compare)(K, K), size_t (*hash)(K)); \
|
FMOD SNAME *PFX##_new(size_t capacity, double load, int (*compare)(K, K), size_t (*hash)(K)); \
|
||||||
FMOD void PFX##_clear(SNAME *_map_); \
|
FMOD void PFX##_clear(SNAME *_map_); \
|
||||||
FMOD void PFX##_free(SNAME *_map_); \
|
FMOD void PFX##_free(SNAME *_map_); \
|
||||||
/* Collection Input and Output */ \
|
/* Collection Input and Output */ \
|
||||||
@@ -220,19 +220,19 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531,
|
|||||||
static SNAME##_iter PFX##_impl_it_start(SNAME *_map_); \
|
static SNAME##_iter PFX##_impl_it_start(SNAME *_map_); \
|
||||||
static SNAME##_iter PFX##_impl_it_end(SNAME *_map_); \
|
static SNAME##_iter PFX##_impl_it_end(SNAME *_map_); \
|
||||||
\
|
\
|
||||||
FMOD SNAME *PFX##_new(size_t size, double load, int (*compare)(K, K), size_t (*hash)(K)) \
|
FMOD SNAME *PFX##_new(size_t capacity, double load, int (*compare)(K, K), size_t (*hash)(K)) \
|
||||||
{ \
|
{ \
|
||||||
if (size == 0 || load <= 0 || load >= 1) \
|
if (capacity == 0 || load <= 0 || load >= 1) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
size_t real_size = PFX##_impl_calculate_size(size); \
|
size_t real_capacity = PFX##_impl_calculate_size(capacity / load); \
|
||||||
\
|
\
|
||||||
SNAME *_map_ = malloc(sizeof(SNAME)); \
|
SNAME *_map_ = malloc(sizeof(SNAME)); \
|
||||||
\
|
\
|
||||||
if (!_map_) \
|
if (!_map_) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
_map_->buffer = malloc(sizeof(SNAME##_entry) * real_size); \
|
_map_->buffer = malloc(sizeof(SNAME##_entry) * real_capacity); \
|
||||||
\
|
\
|
||||||
if (!_map_->buffer) \
|
if (!_map_->buffer) \
|
||||||
{ \
|
{ \
|
||||||
@@ -240,10 +240,10 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531,
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
memset(_map_->buffer, 0, sizeof(SNAME##_entry) * real_size); \
|
memset(_map_->buffer, 0, sizeof(SNAME##_entry) * real_capacity); \
|
||||||
\
|
\
|
||||||
_map_->count = 0; \
|
_map_->count = 0; \
|
||||||
_map_->capacity = real_size; \
|
_map_->capacity = real_capacity; \
|
||||||
_map_->load = load; \
|
_map_->load = load; \
|
||||||
_map_->cmp = compare; \
|
_map_->cmp = compare; \
|
||||||
_map_->hash = hash; \
|
_map_->hash = hash; \
|
||||||
|
|||||||
+7
-7
@@ -146,7 +146,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531,
|
|||||||
\
|
\
|
||||||
/* Collection Functions */ \
|
/* Collection Functions */ \
|
||||||
/* Collection Allocation and Deallocation */ \
|
/* Collection Allocation and Deallocation */ \
|
||||||
FMOD SNAME *PFX##_new(size_t size, double load, int (*compare)(V, V), size_t (*hash)(V)); \
|
FMOD SNAME *PFX##_new(size_t capacity, double load, int (*compare)(V, V), size_t (*hash)(V)); \
|
||||||
FMOD void PFX##_clear(SNAME *_set_); \
|
FMOD void PFX##_clear(SNAME *_set_); \
|
||||||
FMOD void PFX##_free(SNAME *_set_); \
|
FMOD void PFX##_free(SNAME *_set_); \
|
||||||
/* Collection Input and Output */ \
|
/* Collection Input and Output */ \
|
||||||
@@ -213,19 +213,19 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531,
|
|||||||
static SNAME##_iter PFX##_impl_it_start(SNAME *_set_); \
|
static SNAME##_iter PFX##_impl_it_start(SNAME *_set_); \
|
||||||
static SNAME##_iter PFX##_impl_it_end(SNAME *_set_); \
|
static SNAME##_iter PFX##_impl_it_end(SNAME *_set_); \
|
||||||
\
|
\
|
||||||
FMOD SNAME *PFX##_new(size_t size, double load, int (*compare)(V, V), size_t (*hash)(V)) \
|
FMOD SNAME *PFX##_new(size_t capacity, double load, int (*compare)(V, V), size_t (*hash)(V)) \
|
||||||
{ \
|
{ \
|
||||||
if (size == 0 || load <= 0 || load >= 1) \
|
if (capacity == 0 || load <= 0 || load >= 1) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
size_t real_size = PFX##_impl_calculate_size(size); \
|
size_t real_capacity = PFX##_impl_calculate_size(capacity / load); \
|
||||||
\
|
\
|
||||||
SNAME *_set_ = malloc(sizeof(SNAME)); \
|
SNAME *_set_ = malloc(sizeof(SNAME)); \
|
||||||
\
|
\
|
||||||
if (!_set_) \
|
if (!_set_) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
_set_->buffer = malloc(sizeof(SNAME##_entry) * real_size); \
|
_set_->buffer = malloc(sizeof(SNAME##_entry) * real_capacity); \
|
||||||
\
|
\
|
||||||
if (!_set_->buffer) \
|
if (!_set_->buffer) \
|
||||||
{ \
|
{ \
|
||||||
@@ -233,10 +233,10 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531,
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
memset(_set_->buffer, 0, sizeof(SNAME##_entry) * real_size); \
|
memset(_set_->buffer, 0, sizeof(SNAME##_entry) * real_capacity); \
|
||||||
\
|
\
|
||||||
_set_->count = 0; \
|
_set_->count = 0; \
|
||||||
_set_->capacity = real_size; \
|
_set_->capacity = real_capacity; \
|
||||||
_set_->load = load; \
|
_set_->load = load; \
|
||||||
_set_->cmp = compare; \
|
_set_->cmp = compare; \
|
||||||
_set_->hash = hash; \
|
_set_->hash = hash; \
|
||||||
|
|||||||
+6
-6
@@ -83,7 +83,7 @@ typedef enum HeapOrder
|
|||||||
\
|
\
|
||||||
/* Collection Functions */ \
|
/* Collection Functions */ \
|
||||||
/* Collection Allocation and Deallocation */ \
|
/* Collection Allocation and Deallocation */ \
|
||||||
FMOD SNAME *PFX##_new(size_t size, HeapOrder HO, int (*compare)(V, V)); \
|
FMOD SNAME *PFX##_new(size_t capacity, HeapOrder HO, int (*compare)(V, V)); \
|
||||||
FMOD void PFX##_clear(SNAME *_heap_); \
|
FMOD void PFX##_clear(SNAME *_heap_); \
|
||||||
FMOD void PFX##_free(SNAME *_heap_); \
|
FMOD void PFX##_free(SNAME *_heap_); \
|
||||||
/* Collection Input and Output */ \
|
/* Collection Input and Output */ \
|
||||||
@@ -143,9 +143,9 @@ typedef enum HeapOrder
|
|||||||
static SNAME##_iter PFX##_impl_it_start(SNAME *_heap_); \
|
static SNAME##_iter PFX##_impl_it_start(SNAME *_heap_); \
|
||||||
static SNAME##_iter PFX##_impl_it_end(SNAME *_heap_); \
|
static SNAME##_iter PFX##_impl_it_end(SNAME *_heap_); \
|
||||||
\
|
\
|
||||||
FMOD SNAME *PFX##_new(size_t size, HeapOrder HO, int (*compare)(V, V)) \
|
FMOD SNAME *PFX##_new(size_t capacity, HeapOrder HO, int (*compare)(V, V)) \
|
||||||
{ \
|
{ \
|
||||||
if (size < 1) \
|
if (capacity < 1) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
if (HO != MinHeap && HO != MaxHeap) \
|
if (HO != MinHeap && HO != MaxHeap) \
|
||||||
@@ -156,7 +156,7 @@ typedef enum HeapOrder
|
|||||||
if (!_heap_) \
|
if (!_heap_) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
_heap_->buffer = malloc(sizeof(V) * size); \
|
_heap_->buffer = malloc(sizeof(V) * capacity); \
|
||||||
\
|
\
|
||||||
if (!_heap_->buffer) \
|
if (!_heap_->buffer) \
|
||||||
{ \
|
{ \
|
||||||
@@ -164,9 +164,9 @@ typedef enum HeapOrder
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
memset(_heap_->buffer, 0, sizeof(V) * size); \
|
memset(_heap_->buffer, 0, sizeof(V) * capacity); \
|
||||||
\
|
\
|
||||||
_heap_->capacity = size; \
|
_heap_->capacity = capacity; \
|
||||||
_heap_->count = 0; \
|
_heap_->count = 0; \
|
||||||
_heap_->HO = HO; \
|
_heap_->HO = HO; \
|
||||||
_heap_->cmp = compare; \
|
_heap_->cmp = compare; \
|
||||||
|
|||||||
+6
-6
@@ -80,7 +80,7 @@
|
|||||||
\
|
\
|
||||||
/* Collection Functions */ \
|
/* Collection Functions */ \
|
||||||
/* Collection Allocation and Deallocation */ \
|
/* Collection Allocation and Deallocation */ \
|
||||||
FMOD SNAME *PFX##_new(size_t size); \
|
FMOD SNAME *PFX##_new(size_t capacity); \
|
||||||
FMOD void PFX##_clear(SNAME *_queue_); \
|
FMOD void PFX##_clear(SNAME *_queue_); \
|
||||||
FMOD void PFX##_free(SNAME *_queue_); \
|
FMOD void PFX##_free(SNAME *_queue_); \
|
||||||
/* Collection Input and Output */ \
|
/* Collection Input and Output */ \
|
||||||
@@ -135,9 +135,9 @@
|
|||||||
static SNAME##_iter PFX##_impl_it_start(SNAME *_queue_); \
|
static SNAME##_iter PFX##_impl_it_start(SNAME *_queue_); \
|
||||||
static SNAME##_iter PFX##_impl_it_end(SNAME *_queue_); \
|
static SNAME##_iter PFX##_impl_it_end(SNAME *_queue_); \
|
||||||
\
|
\
|
||||||
FMOD SNAME *PFX##_new(size_t size) \
|
FMOD SNAME *PFX##_new(size_t capacity) \
|
||||||
{ \
|
{ \
|
||||||
if (size < 1) \
|
if (capacity < 1) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
SNAME *_queue_ = malloc(sizeof(SNAME)); \
|
SNAME *_queue_ = malloc(sizeof(SNAME)); \
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
if (!_queue_) \
|
if (!_queue_) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
_queue_->buffer = malloc(sizeof(V) * size); \
|
_queue_->buffer = malloc(sizeof(V) * capacity); \
|
||||||
\
|
\
|
||||||
if (!_queue_->buffer) \
|
if (!_queue_->buffer) \
|
||||||
{ \
|
{ \
|
||||||
@@ -153,9 +153,9 @@
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
memset(_queue_->buffer, 0, sizeof(V) * size); \
|
memset(_queue_->buffer, 0, sizeof(V) * capacity); \
|
||||||
\
|
\
|
||||||
_queue_->capacity = size; \
|
_queue_->capacity = capacity; \
|
||||||
_queue_->count = 0; \
|
_queue_->count = 0; \
|
||||||
_queue_->front = 0; \
|
_queue_->front = 0; \
|
||||||
_queue_->rear = 0; \
|
_queue_->rear = 0; \
|
||||||
|
|||||||
+5
-5
@@ -71,7 +71,7 @@
|
|||||||
\
|
\
|
||||||
/* Collection Functions */ \
|
/* Collection Functions */ \
|
||||||
/* Collection Allocation and Deallocation */ \
|
/* Collection Allocation and Deallocation */ \
|
||||||
FMOD SNAME *PFX##_new(size_t size); \
|
FMOD SNAME *PFX##_new(size_t capacity); \
|
||||||
FMOD void PFX##_clear(SNAME *_stack_); \
|
FMOD void PFX##_clear(SNAME *_stack_); \
|
||||||
FMOD void PFX##_free(SNAME *_stack_); \
|
FMOD void PFX##_free(SNAME *_stack_); \
|
||||||
/* Collection Input and Output */ \
|
/* Collection Input and Output */ \
|
||||||
@@ -126,9 +126,9 @@
|
|||||||
static SNAME##_iter PFX##_impl_it_start(SNAME *_stack_); \
|
static SNAME##_iter PFX##_impl_it_start(SNAME *_stack_); \
|
||||||
static SNAME##_iter PFX##_impl_it_end(SNAME *_stack_); \
|
static SNAME##_iter PFX##_impl_it_end(SNAME *_stack_); \
|
||||||
\
|
\
|
||||||
FMOD SNAME *PFX##_new(size_t size) \
|
FMOD SNAME *PFX##_new(size_t capacity) \
|
||||||
{ \
|
{ \
|
||||||
if (size < 1) \
|
if (capacity < 1) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
SNAME *_stack_ = malloc(sizeof(SNAME)); \
|
SNAME *_stack_ = malloc(sizeof(SNAME)); \
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
if (!_stack_) \
|
if (!_stack_) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
_stack_->buffer = malloc(sizeof(V) * size); \
|
_stack_->buffer = malloc(sizeof(V) * capacity); \
|
||||||
\
|
\
|
||||||
if (!_stack_->buffer) \
|
if (!_stack_->buffer) \
|
||||||
{ \
|
{ \
|
||||||
@@ -146,7 +146,7 @@
|
|||||||
\
|
\
|
||||||
memset(_stack_->buffer, 0, sizeof(V) * size); \
|
memset(_stack_->buffer, 0, sizeof(V) * size); \
|
||||||
\
|
\
|
||||||
_stack_->capacity = size; \
|
_stack_->capacity = capacity; \
|
||||||
_stack_->count = 0; \
|
_stack_->count = 0; \
|
||||||
\
|
\
|
||||||
_stack_->it_start = PFX##_impl_it_start; \
|
_stack_->it_start = PFX##_impl_it_start; \
|
||||||
|
|||||||
Reference in new issue
Block a user