Hans Leidekker wrote:
> +
> +/***********************************************************************
> + * SnmpUtilVarBindListCpy (SNMPAPI.@)
> + */
> +INT WINAPI SnmpUtilVarBindListCpy(SnmpVarBindList *dst, SnmpVarBindList *src)
> +{
> + unsigned int i, size;
> + SnmpVarBind *src_entry, *dst_entry;
> +
> + TRACE("(%p, %p)\n", dst, src);
> +
> + size = sizeof(SnmpVarBindList);
> + if (!(dst = HeapAlloc(GetProcessHeap(), 0, size))) return SNMPAPI_ERROR;
>
Where do you return this memory to the caller?
> +
> + size = src->len * sizeof(SnmpVarBind *);
> + if (!(dst->list = HeapAlloc(GetProcessHeap(), 0, size)))
> + {
> + HeapFree(GetProcessHeap(), 0, dst);
> + return SNMPAPI_ERROR;
> + }
> + src_entry = src->list;
> + dst_entry = dst->list;
> + for (i = 0; i < src->len; i++)
> + {
> + if (SnmpUtilVarBindCpy(dst_entry, src_entry))
> + {
> + src_entry++;
> + dst_entry++;
> + }
> + else
> + {
> + for (--i; i > 0; i--) SnmpUtilVarBindFree(--dst_entry);
> + HeapFree(GetProcessHeap(), 0, dst->list);
> + HeapFree(GetProcessHeap(), 0, dst);
> + return SNMPAPI_ERROR;
> + }
> + }
> + dst->len = src->len;
> + return SNMPAPI_NOERROR;
> +}
>
>
--
Rob Shearman