Rename the vector's Max field to Capacity
This commit is contained in:
+2
-2
@@ -709,13 +709,13 @@ ALboolean vector_reserve(void *ptr, size_t orig_count, size_t base_size, size_t
|
||||
void *temp;
|
||||
|
||||
/* Need to be explicit with the caller type's base size, because it
|
||||
* could have extra padding between the count and array start (that is,
|
||||
* could have extra padding before the start of the array (that is,
|
||||
* sizeof(*vector_) may not equal base_size). */
|
||||
temp = realloc(*vecptr, base_size + obj_size*obj_count);
|
||||
if(temp == NULL) return AL_FALSE;
|
||||
|
||||
*vecptr = temp;
|
||||
(*vecptr)->Max = obj_count;
|
||||
(*vecptr)->Capacity = obj_count;
|
||||
}
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
+8
-8
@@ -349,12 +349,12 @@ static GenModList GenModList_clone(const GenModList *self)
|
||||
GenModList ret;
|
||||
|
||||
GenModList_Construct(&ret);
|
||||
VECTOR_RESERVE(ret.gens, VECTOR_MAX(self->gens));
|
||||
VECTOR_RESERVE(ret.gens, VECTOR_CAPACITY(self->gens));
|
||||
memcpy(ret.gens, self->gens, sizeof(ret.gens) +
|
||||
VECTOR_MAX(ret.gens) * sizeof(ret.gens->Data[0]));
|
||||
VECTOR_RESERVE(ret.mods, VECTOR_MAX(self->mods));
|
||||
VECTOR_CAPACITY(ret.gens) * sizeof(ret.gens->Data[0]));
|
||||
VECTOR_RESERVE(ret.mods, VECTOR_CAPACITY(self->mods));
|
||||
memcpy(ret.mods, self->mods, sizeof(ret.mods) +
|
||||
VECTOR_MAX(ret.mods) * sizeof(ret.mods->Data[0]));
|
||||
VECTOR_CAPACITY(ret.mods) * sizeof(ret.mods->Data[0]));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ static void GenModList_insertGen(GenModList *self, const Generator *gen, ALboole
|
||||
if(VECTOR_RESERVE(self->gens, NextPowerOf2(VECTOR_SIZE(self->gens)+1)) == AL_FALSE)
|
||||
{
|
||||
ERR("Failed to increase generator storage to %d elements (from %d)\n",
|
||||
NextPowerOf2(VECTOR_SIZE(self->gens)+1), VECTOR_MAX(self->gens));
|
||||
NextPowerOf2(VECTOR_SIZE(self->gens)+1), VECTOR_CAPACITY(self->gens));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ static void GenModList_accumGen(GenModList *self, const Generator *gen)
|
||||
if(VECTOR_RESERVE(self->gens, NextPowerOf2(VECTOR_SIZE(self->gens)+1)) == AL_FALSE)
|
||||
{
|
||||
ERR("Failed to increase generator storage to %d elements (from %d)\n",
|
||||
NextPowerOf2(VECTOR_SIZE(self->gens)+1), VECTOR_MAX(self->gens));
|
||||
NextPowerOf2(VECTOR_SIZE(self->gens)+1), VECTOR_CAPACITY(self->gens));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ static void GenModList_insertMod(GenModList *self, const Modulator *mod)
|
||||
if(VECTOR_RESERVE(self->mods, NextPowerOf2(VECTOR_SIZE(self->mods)+1)) == AL_FALSE)
|
||||
{
|
||||
ERR("Failed to increase modulator storage to %d elements (from %d)\n",
|
||||
NextPowerOf2(VECTOR_SIZE(self->mods)+1), VECTOR_MAX(self->mods));
|
||||
NextPowerOf2(VECTOR_SIZE(self->mods)+1), VECTOR_CAPACITY(self->mods));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ static void GenModList_accumMod(GenModList *self, const Modulator *mod)
|
||||
if(VECTOR_RESERVE(self->mods, NextPowerOf2(VECTOR_SIZE(self->mods)+1)) == AL_FALSE)
|
||||
{
|
||||
ERR("Failed to increase modulator storage to %d elements (from %d)\n",
|
||||
NextPowerOf2(VECTOR_SIZE(self->mods)+1), VECTOR_MAX(self->mods));
|
||||
NextPowerOf2(VECTOR_SIZE(self->mods)+1), VECTOR_CAPACITY(self->mods));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -7,12 +7,12 @@
|
||||
|
||||
/* "Base" vector type, designed to alias with the actual vector types. */
|
||||
typedef struct vector__s {
|
||||
ALsizei Max;
|
||||
ALsizei Capacity;
|
||||
ALsizei Size;
|
||||
} *vector_;
|
||||
|
||||
#define DECL_VECTOR(T) typedef struct vector_##T##_s { \
|
||||
ALsizei Max; \
|
||||
ALsizei Capacity; \
|
||||
ALsizei Size; \
|
||||
T Data[]; \
|
||||
} *vector_##T;
|
||||
@@ -22,10 +22,10 @@ typedef struct vector__s {
|
||||
|
||||
/* Helper to increase a vector's reserve. Do not call directly. */
|
||||
ALboolean vector_reserve(void *ptr, size_t orig_count, size_t base_size, size_t obj_count, size_t obj_size);
|
||||
#define VECTOR_RESERVE(_x, _c) (vector_reserve(&(_x), (_x)->Max, sizeof(*(_x)), (_c), sizeof((_x)->Data[0])))
|
||||
#define VECTOR_RESERVE(_x, _c) (vector_reserve(&(_x), (_x)->Capacity, sizeof(*(_x)), (_c), sizeof((_x)->Data[0])))
|
||||
|
||||
#define VECTOR_SIZE(_x) ((const ALsizei)(_x)->Size)
|
||||
#define VECTOR_MAX(_x) ((const ALsizei)(_x)->Max)
|
||||
#define VECTOR_CAPACITY(_x) ((const ALsizei)(_x)->Capacity)
|
||||
#define VECTOR_SIZE(_x) ((const ALsizei)(_x)->Size)
|
||||
|
||||
#define VECTOR_ITER_BEGIN(_x) ((_x)->Data)
|
||||
#define VECTOR_ITER_END(_x) ((_x)->Data + (_x)->Size)
|
||||
|
||||
Reference in New Issue
Block a user