Remove redundant check-ptr usage

release
Slava Pestov 2007-11-09 03:19:01 -05:00
parent 1a53979740
commit 04a5c54e08
3 changed files with 3 additions and 4 deletions

View File

@ -26,8 +26,7 @@ HELP: memcpy
HELP: check-ptr
{ $values { "c-ptr" "an alien address, byte array, or " { $link f } } { "checked" "an alien address or byte array with non-zero address" } }
{ $description "Throws an error if the input is " { $link f } ". Otherwise the object remains on the data stack. This word should be used to check the return values of " { $link malloc } " and " { $link realloc } " before use." }
{ $error-description "Callers of " { $link malloc } " and " { $link realloc } " should use " { $link check-ptr } " to throw an error in the case of a memory allocation failure." } ;
{ $description "Throws an error if the input is " { $link f } ". Otherwise the object remains on the data stack." } ;
HELP: free
{ $values { "alien" c-ptr } }

View File

@ -84,4 +84,4 @@ PRIVATE>
"void" "libc" "memcpy" { "void*" "void*" "ulong" } alien-invoke ;
: with-malloc ( size quot -- )
swap 1 calloc check-ptr swap keep free ; inline
swap 1 calloc swap keep free ; inline

View File

@ -79,7 +79,7 @@ HINTS: search-buffer-until { fixnum fixnum simple-alien string } ;
buffer-fill zero? ;
: extend-buffer ( n buffer -- )
2dup buffer-ptr swap realloc check-ptr
2dup buffer-ptr swap realloc
over set-buffer-ptr set-buffer-size ;
: check-overflow ( n buffer -- )