From: Jeremy Allison Date: Tue, 25 Aug 2020 17:22:10 +0000 (-0700) Subject: s3: libsmb: Add utility funtion dup_ip_service_array(). X-Git-Tag: talloc-2.3.2~629 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=02016acb2d8b7b5432406942e49d229fe1d024b5;p=thirdparty%2Fsamba.git s3: libsmb: Add utility funtion dup_ip_service_array(). Preparing to return ip_service arrays as talloc, not malloc. Commented out as not yet used. Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 2a91ec4e98d..d1135e65d3d 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -64,6 +64,31 @@ bool sockaddr_storage_to_samba_sockaddr(struct samba_sockaddr *sa, return true; } +#if 0 +/* + * Utility function to convert a MALLOC'ed struct ip_serivce array + * to a talloc'ed one. This function will go away once all ip_service + * arrays are talloc'ed. + */ + +static NTSTATUS dup_ip_service_array(TALLOC_CTX *ctx, + struct ip_service **array_out, + const struct ip_service *array_in, + size_t count) +{ + struct ip_service *array_copy = NULL; + + array_copy = talloc_memdup(ctx, + array_in, + count * sizeof(array_in[0])); + if (array_copy == NULL) { + return NT_STATUS_NO_MEMORY; + } + *array_out = array_copy; + return NT_STATUS_OK; +} +#endif + /**************************** * SERVER AFFINITY ROUTINES * ****************************/