This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/cdutz/go-ads-ng
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/feature/cdutz/go-ads-ng by 
this push:
     new 9a014f458 feat(ads): ADS Auto-Discovery
9a014f458 is described below

commit 9a014f45815dc269137bd6462aa2a4cfe59a971d
Author: Christofer Dutz <[email protected]>
AuthorDate: Thu Nov 3 18:25:23 2022 +0100

    feat(ads): ADS Auto-Discovery
    
    - Made the buffer allocation actually work nicely.
---
 plc4go/internal/ads/Discoverer.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/plc4go/internal/ads/Discoverer.go 
b/plc4go/internal/ads/Discoverer.go
index 62e2c8fb6..ee5a8a0c1 100644
--- a/plc4go/internal/ads/Discoverer.go
+++ b/plc4go/internal/ads/Discoverer.go
@@ -214,7 +214,8 @@ func (d *Discoverer) Discover(ctx context.Context, callback 
func(event apiModel.
                                discoveryRequestMessage := 
model.NewAdsDiscovery(0, model.Operation_DISCOVERY_REQUEST, amsNetId, 
model.AdsPortNumbers_SYSTEM_SERVICE, []model.AdsDiscoveryBlock{})
 
                                // Serialize the message
-                               buffer := bytes.NewBuffer(make([]byte, 
discoveryRequestMessage.GetLengthInBytes()))
+                               buffer := new(bytes.Buffer)
+                               
buffer.Grow(int(discoveryRequestMessage.GetLengthInBytes()))
                                writeBuffer := 
utils.NewCustomWriteBufferByteBased(buffer, binary.LittleEndian)
                                discoveryRequestMessage.Serialize(writeBuffer)
 

Reply via email to