mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 10:19:51 +00:00
Tweaks
This commit is contained in:
parent
d36543b204
commit
c694f1a4a9
1 changed files with 12 additions and 6 deletions
|
|
@ -204,7 +204,7 @@ STATIC_INLINE int template_callback_raw(unpack_user* u PERL_UNUSED_DECL, const c
|
|||
|
||||
#include "msgpack/unpack_template.h"
|
||||
|
||||
STATIC_INLINE SV* _msgpack_unpack(SV* data, int limit) {
|
||||
STATIC_INLINE SV* _msgpack_unpack(SV* data, size_t limit PERL_UNUSED_DECL) {
|
||||
msgpack_unpack_t mp;
|
||||
dTHX;
|
||||
unpack_user u = {0, &PL_sv_undef, false};
|
||||
|
|
@ -252,14 +252,20 @@ XS(xs_unpack_limit) {
|
|||
|
||||
XS(xs_unpack) {
|
||||
dXSARGS;
|
||||
SV* const data = ST(1);
|
||||
size_t limit;
|
||||
|
||||
if (items != 2) {
|
||||
Perl_croak(aTHX_ "Usage: Data::MessagePack->unpack('datadata')");
|
||||
if (items == 2) {
|
||||
limit = sv_len(data);
|
||||
}
|
||||
else if(items == 3) {
|
||||
limit = SvUVx(ST(2));
|
||||
}
|
||||
else {
|
||||
Perl_croak(aTHX_ "Usage: Data::MessagePack->unpack('data' [, $limit])");
|
||||
}
|
||||
|
||||
{
|
||||
ST(0) = _msgpack_unpack(ST(1), sv_len(ST(1)));
|
||||
}
|
||||
ST(0) = _msgpack_unpack(data, limit);
|
||||
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue