Skip to content

Commit

Permalink
Fix compiler errors
Browse files Browse the repository at this point in the history
  • Loading branch information
detomon committed Dec 14, 2024
1 parent 774d604 commit 3080c4f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/BKBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include <stdlib.h>
#include <string.h>

#ifdef _MSC_VER
#define alloca _alloca
#endif

#define BK_INLINE static inline

/**
Expand Down
2 changes: 1 addition & 1 deletion src/BKContext.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ BKInt BKContextGenerateToTime(BKContext* ctx, BKTime endTime, BKInt (*write)(BKF
// write frames if buffer filled or end time is reached
if (BKBufferSize(&ctx->channels[0]) >= BK_MAX_GENERATE_SAMPLES || BKTimeIsGreaterEqual(ctx->currentTime, endTime)) {
BKInt size;
BKFrame* frames = alloca(ctx->numChannels * BK_MAX_GENERATE_SAMPLES);
BKFrame* frames = (BKFrame*)alloca(sizeof(BKFrame) * ctx->numChannels * BK_MAX_GENERATE_SAMPLES);

size = BKContextRead(ctx, frames, BK_MAX_GENERATE_SAMPLES);
numFrames += size;
Expand Down
4 changes: 2 additions & 2 deletions src/BKData.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ static BKInt BKDataConvertFromBits(BKFrame* outFrames, void const* data, BKUInt

dataSize -= (dataSize % (mask * numChannels));

for (charData = data; (void*)charData < data + dataSize;) {
for (charData = data; charData < (unsigned char*)data + dataSize;) {
switch (numBits) {
case 1: {
c = charData[0];
Expand Down Expand Up @@ -522,7 +522,7 @@ static BKInt BKDataConvertFromBits(BKFrame* outFrames, void const* data, BKUInt
}
case 16: {
if (reverseEndian) {
outFrames[0] = (charData[0] << 8) | (charData[1] >> 8);
outFrames[0] = ((BKFrame)charData[0] << 8) | ((BKFrame)charData[1] >> 8);
}
else {
outFrames[0] = (*(BKFrame*)charData);
Expand Down
8 changes: 4 additions & 4 deletions src/BKSequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static BKInt BKSequenceFuncSimpleCreate(BKSequence** outSequence, BKSequenceFunc
if (sequence) {
memset(sequence, 0, sizeof(*sequence));

sequence->values = (void*)sequence + sizeof(*sequence);
sequence->values = (char*)sequence + sizeof(*sequence);

memcpy(sequence->values, values, size);

Expand Down Expand Up @@ -112,7 +112,7 @@ static BKInt BKSequenceFuncSimpleCopy(BKSequence** outCopy, BKSequence const* se
BKSequence* copy = malloc(sizeof(*copy) + size);

if (copy) {
values = (void*)copy + sizeof(*copy);
values = (BKInt*)((char*)copy + sizeof(*copy));
copy->values = values;

memcpy(copy, sequence, sizeof(*copy));
Expand Down Expand Up @@ -202,7 +202,7 @@ static BKInt BKSequenceFuncEnvelopeCreate(BKSequence** outSequence, BKSequenceFu
if (sequence) {
memset(sequence, 0, sizeof(*sequence));

sequence->values = (void*)sequence + sizeof(*sequence);
sequence->values = (char*)sequence + sizeof(*sequence);

memcpy(sequence->values, values, size);

Expand Down Expand Up @@ -355,7 +355,7 @@ static BKInt BKSequenceFuncEnvelopeCopy(BKSequence** outCopy, BKSequence const*
copy = malloc(sizeof(*copy) + size);

if (copy) {
values = (void*)copy + sizeof(*copy);
values = (BKSequencePhase*)((char*)copy + sizeof(*copy));
copy->values = values;

memcpy(copy, sequence, sizeof(*copy));
Expand Down
2 changes: 1 addition & 1 deletion src/BKTrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ BKInt BKTrackGetEffect(BKTrack const* track, BKEnum effect, void* outValues, BKU
// copy values
memcpy(outValues, values, outSize);
// empty trailing data
memset((void*)outValues + outSize, 0, BKMax(0, (BKInt)size - outSize));
memset((char*)outValues + outSize, 0, BKMax(0, (BKInt)size - outSize));

return 0;
}
Expand Down

0 comments on commit 3080c4f

Please sign in to comment.