Skip to content

Commit

Permalink
remove unsafe pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas committed Jan 4, 2020
1 parent 0419d84 commit a3327b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ var (

type bctx struct{ n string }

func getCtxData(b *Bridge) (unsafe.Pointer, error) {
func getCtxData(b *Bridge) (*bctx, error) {
mu.Lock()
defer mu.Unlock()
if _, ok := bridges[b.name]; ok {
return nil, fmt.Errorf("bridge with name %s already exists", b.name)
}

bridges[b.name] = b
return unsafe.Pointer(&bctx{n: b.name}), nil
return &bctx{n: b.name}, nil
}

func getBridge(ctx unsafe.Pointer) *Bridge {
ictx := wasmer.IntoInstanceContext(ctx)
c := (*bctx)((ictx.Data()).(unsafe.Pointer))
c := (ictx.Data()).(*bctx)
mu.RLock()
defer mu.RUnlock()
return bridges[c.n]
Expand Down

0 comments on commit a3327b9

Please sign in to comment.