Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix two argument form of ffi.fill

Fixes #44
  • Loading branch information...
commit 26fbafc6cd0187ac46971a3a4387a8f1dc2c4e8e 1 parent 5f82a7a
James McKaskill jmckaskill authored

Showing 2 changed files with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 2 ffi.c
  2. +5 0 test.lua
8 ffi.c
@@ -2445,10 +2445,14 @@ static int ffi_copy(lua_State* L)
2445 2445 static int ffi_fill(lua_State* L)
2446 2446 {
2447 2447 struct ctype ct;
2448   - void* to = check_pointer(L, 1, &ct);
2449   - size_t sz = (size_t) luaL_checknumber(L, 2);
  2448 + void* to;
  2449 + size_t sz;
2450 2450 int val = 0;
2451 2451
  2452 + setmintop(L, 3);
  2453 + to = check_pointer(L, 1, &ct);
  2454 + sz = (size_t) luaL_checknumber(L, 2);
  2455 +
2452 2456 if (!lua_isnoneornil(L, 3)) {
2453 2457 val = (int) luaL_checkinteger(L, 3);
2454 2458 }
5 test.lua
@@ -813,5 +813,10 @@ int strncmp(const signed char *s1, const unsigned char *s2, size_t n);
813 813 ]]
814 814 assert(ffi.C.strncmp("two", "three", 3) ~= 0)
815 815
  816 +ffi.fill(d, 3, 1)
  817 +assert(d[2] == 1)
  818 +ffi.fill(d, 3)
  819 +assert(d[2] == 0)
  820 +
816 821 print('Test PASSED')
817 822

0 comments on commit 26fbafc

Please sign in to comment.
Something went wrong with that request. Please try again.