diff options
| author | Ken Thompson <ken@golang.org> | 2009-11-17 20:41:44 -0800 |
|---|---|---|
| committer | Ken Thompson <ken@golang.org> | 2009-11-17 20:41:44 -0800 |
| commit | c4606d05da2d4ae7bfb32def1e9df2092e4a9da4 (patch) | |
| tree | cc48862b2b903f5bacb744c888eb0a64d1642cc5 /src/pkg/runtime/slice.c | |
| parent | a8ba40823c08508ca5f7562501a26bc2e85c88eb (diff) | |
| download | go-c4606d05da2d4ae7bfb32def1e9df2092e4a9da4.tar.xz | |
install copy predefined
did not test 386, but should work
shouldnt matter if copy is not used
R=rsc
https://golang.org/cl/156055
Diffstat (limited to 'src/pkg/runtime/slice.c')
| -rw-r--r-- | src/pkg/runtime/slice.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/pkg/runtime/slice.c b/src/pkg/runtime/slice.c index 722802c004..00d9724fbe 100644 --- a/src/pkg/runtime/slice.c +++ b/src/pkg/runtime/slice.c @@ -177,6 +177,39 @@ runtime·arraytoslice(byte* old, uint32 nel, Slice ret) } } +// slicecopy(to any, fr any, wid uint32) int +void +runtime·slicecopy(Slice to, Slice fm, uintptr width, int32 ret) +{ + if(fm.array == nil || fm.len == 0 || + to.array == nil || to.len == 0 || + width == 0) { + ret = 0; + goto out; + } + + ret = fm.len; + if(to.len > ret) + ret = to.len; + + memmove(to.array, fm.array, ret*width); + +out: + FLUSH(&ret); + + if(debug) { + prints("main·copy: to="); + runtime·printslice(to); + prints("; fm="); + runtime·printslice(fm); + prints("; width="); + runtime·printint(width); + prints("; ret="); + runtime·printint(ret); + prints("\n"); + } +} + void runtime·printslice(Slice a) { |
