9
9
"encoding/binary"
10
10
"errors"
11
11
"math/bits"
12
- "runtime"
13
12
"strconv"
14
13
"strings"
15
14
"sync"
@@ -304,25 +303,6 @@ func newOpenSSLError(msg string) error {
304
303
return errors .New (b .String ())
305
304
}
306
305
307
- var unknownFile = "<go code>\000 "
308
-
309
- // caller reports file and line number information about function invocations on
310
- // the calling goroutine's stack, in a form suitable for passing to C code.
311
- // The argument skip is the number of stack frames to ascend, with 0 identifying
312
- // the caller of caller. The return values report the file name and line number
313
- // within the file of the corresponding call. The returned file is a C string
314
- // with static storage duration.
315
- func caller (skip int ) (file * C.char , line C.int ) {
316
- _ , f , l , ok := runtime .Caller (skip + 1 )
317
- if ! ok {
318
- f = unknownFile
319
- }
320
- // The underlying bytes of the file string are null-terminated rodata with
321
- // static lifetimes, so can be safely passed to C without worrying about
322
- // leaking memory or use-after-free.
323
- return (* C .char )(noescape (unsafe .Pointer (unsafe .StringData (f )))), C .int (l )
324
- }
325
-
326
306
// cryptoMalloc allocates n bytes of memory on the OpenSSL heap, which may be
327
307
// different from the heap which C.malloc allocates on. The allocated object
328
308
// must be freed using cryptoFree. cryptoMalloc is equivalent to the
@@ -335,8 +315,7 @@ func caller(skip int) (file *C.char, line C.int) {
335
315
// freed by OPENSSL_free / CRYPTO_free) need to be allocated on the OpenSSL
336
316
// heap.
337
317
func cryptoMalloc (n int ) unsafe.Pointer {
338
- file , line := caller (1 )
339
- p := C .go_openssl_CRYPTO_malloc (C .size_t (n ), file , line )
318
+ p := C .go_openssl_CRYPTO_malloc (C .size_t (n ), nil , 0 )
340
319
if p == nil {
341
320
// Un-recover()-ably crash the program in the same manner as the
342
321
// C.malloc() wrapper function.
@@ -349,8 +328,7 @@ func cryptoMalloc(n int) unsafe.Pointer {
349
328
// different from the heap which C.malloc allocates on. cryptoFree is equivalent
350
329
// to the OPENSSL_free macro.
351
330
func cryptoFree (p unsafe.Pointer ) {
352
- file , line := caller (1 )
353
- C .go_openssl_CRYPTO_free (p , file , line )
331
+ C .go_openssl_CRYPTO_free (p , nil , 0 )
354
332
}
355
333
356
334
const wordBytes = bits .UintSize / 8
0 commit comments