summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--API.md4
-rw-r--r--ReiLua_API.lua6
-rw-r--r--examples/compressed_resource_file/main.lua2
-rw-r--r--src/core.c15
4 files changed, 13 insertions, 14 deletions
diff --git a/API.md b/API.md
index 7ed941c..468eb89 100644
--- a/API.md
+++ b/API.md
@@ -5502,9 +5502,9 @@ Unload buffer data
---
-> RL.CopyBufferData( Buffer dst, Buffer src, int posDst, int posSrc, int length )
+> RL.CopyBufferData( Buffer dst, Buffer src, int posDst, int posSrc, int size )
-Copy buffer data to another buffer. src element size is used for length
+Copy buffer data to another buffer. Size is in bytes
---
diff --git a/ReiLua_API.lua b/ReiLua_API.lua
index 4b21104..5006d3a 100644
--- a/ReiLua_API.lua
+++ b/ReiLua_API.lua
@@ -2660,14 +2660,14 @@ function RL.LoadBufferFromString( buffer ) end
---@return any RL.UnloadBuffer
function RL.UnloadBuffer( buffer ) end
----Copy buffer data to another buffer. src element size is used for length
+---Copy buffer data to another buffer. Size is in bytes
---@param dst any
---@param src any
---@param posDst integer
---@param posSrc integer
----@param length integer
+---@param size integer
---@return any RL.CopyBufferData
-function RL.CopyBufferData( dst, src, posDst, posSrc, length ) end
+function RL.CopyBufferData( dst, src, posDst, posSrc, size ) end
---Set buffer data value
---@param buffer any
diff --git a/examples/compressed_resource_file/main.lua b/examples/compressed_resource_file/main.lua
index 0f9f904..ae37f3f 100644
--- a/examples/compressed_resource_file/main.lua
+++ b/examples/compressed_resource_file/main.lua
@@ -61,7 +61,7 @@ local function loadDataFile( path )
imgData.data = RL.LoadBufferFormatted( imageDataSize, RL.BUFFER_UNSIGNED_CHAR, 0 )
- RL.CopyBufferData( imgData.data, buffer, 0, 4, imageDataSize / 4 )
+ RL.CopyBufferData( imgData.data, buffer, 0, 4, imageDataSize )
local image = RL.LoadImageFromData(
imgData.data,
diff --git a/src/core.c b/src/core.c
index cdead53..4607ef6 100644
--- a/src/core.c
+++ b/src/core.c
@@ -3494,7 +3494,7 @@ int lcoreLoadBufferFromFile( lua_State* L ) {
lua_pushnil( L );
return 1;
}
- fread( buffer.data, buffer.size, 1, file );
+ fread( buffer.data, 1, buffer.size, file );
fclose( file );
uluaPushBuffer( L, buffer );
@@ -3541,28 +3541,27 @@ int lcoreUnloadBuffer( lua_State* L ) {
}
/*
-> RL.CopyBufferData( Buffer dst, Buffer src, int posDst, int posSrc, int length )
+> RL.CopyBufferData( Buffer dst, Buffer src, int posDst, int posSrc, int size )
-Copy buffer data to another buffer. src element size is used for length
+Copy buffer data to another buffer. Size is in bytes
*/
int lcoreCopyBufferData( lua_State* L ) {
Buffer* dst = uluaGetBuffer( L, 1 );
Buffer* src = uluaGetBuffer( L, 2 );
int posDst = luaL_checkinteger( L, 3 );
int posSrc = luaL_checkinteger( L, 4 );
- int length = luaL_checkinteger( L, 5 );
+ int size = luaL_checkinteger( L, 5 );
void* dstP = dst->data + posDst * getBufferElementSize( dst );
void* srcP = src->data + posSrc * getBufferElementSize( src );
- size_t size = length * getBufferElementSize( src );
/* Note that we use src element size for dst length. */
if ( posDst < 0 || dst->size < posDst * getBufferElementSize( dst ) + size ) {
- TraceLog( state->logLevelInvalid, "CopyBufferData. posDst %d with length %d out of bounds", posDst, length );
+ TraceLog( state->logLevelInvalid, "CopyBufferData. posDst %d with size %d out of bounds", posDst, size );
return 0;
}
if ( posSrc < 0 || src->size < posSrc * getBufferElementSize( src ) + size ) {
- TraceLog( state->logLevelInvalid, "CopyBufferData. posSrc %d with length %d out of bounds", posSrc, length );
+ TraceLog( state->logLevelInvalid, "CopyBufferData. posSrc %d with size %d out of bounds", posSrc, size );
return 0;
}
memcpy( dstP, srcP, size );
@@ -3809,7 +3808,7 @@ int lcoreExportBuffer( lua_State* L ) {
FILE* file;
file = fopen( path, "wb" );
- fwrite( buffer->data, buffer->size, 1, file );
+ fwrite( buffer->data, 1, buffer->size, file );
fclose( file );
return 0;