This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2000-2016 Apple Inc. All rights reserved. | |
* | |
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
* | |
* This file contains Original Code and/or Modifications of Original Code | |
* as defined in and that are subject to the Apple Public Source License | |
* Version 2.0 (the 'License'). You may not use this file except in | |
* compliance with the License. The rights granted to you under the License | |
* may not be used to create, or enable the creation or redistribution of, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Bindings for the C `malloc` API to Rust allocators. | |
//! | |
//! This crate provides a mechanism to construct a C allocator - an implementation of `malloc`, | |
//! `free`, and related functions - that is backed by a Rust allocator (an implementation of the | |
//! `Alloc` trait). | |
//! | |
//! In order to create bindings, two things must be provided: an implementation of the `Alloc` | |
//! trait, and an implementation of the `LayoutFinder` trait (defined in this crate). Since the C | |
//! API does not provide size or alignment on `free`, but the Rust `Alloc` API requires both size | |
//! and alignment on `dealloc`, a mapping must be maintained between allocated objects and those |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an example of a self-cleaning worker. A common pattern in Go | |
// is to have a type which, when created with NewX, spawns one or more | |
// goroutines in the background to perform work. It is usually the | |
// caller's responsibility to call Close() or Stop() in order to shut | |
// these workers down and not leak goroutines and the memory resources | |
// that the goroutines have references to. | |
// | |
// The idea behind a self-cleaning worker is to leverage the runtime's | |
// ability to set finalizers on objects in order to detect when an object | |
// with a still-live worker goroutine has gone out of scope. The type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build !build_source | |
//go:binary-only-package | |
package bug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sort | |
import ( | |
"math/rand" | |
"sort" | |
"testing" | |
) | |
func TestSort(t *testing.T) { | |
for i := 0; i < 100; i++ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sort | |
import ( | |
"fmt" | |
"reflect" | |
"sort" | |
"sync" | |
"unsafe" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"net" | |
"os" | |
"github.com/synful/rate" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
long *i; | |
long arr[64]; | |
for (i = arr; i < arr + (64 * sizeof(arr)); i++) { | |
*i = (long)arr; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The *Rand type here is essentially equivalent to the standard library's | |
math/rand.Rand, albeit with a few additions for types (to randomly | |
generate strings, bools, etc). | |
*/ | |
package rand | |
import ( | |
"reflect" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
"runtime" | |
) | |
func main() { | |
fmt.Println(runtime.FuncForPC(reflect.ValueOf(main).Pointer()).Name()) |
NewerOlder