From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B621A24D30 for ; Thu, 24 May 2018 03:32:52 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N-6i45QZeA7W for ; Thu, 24 May 2018 03:32:52 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 0267524D2F for ; Thu, 24 May 2018 03:32:51 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v7 2/7] box: introduce OPT_ARRAY opt_type to decode arrays References: <20180523175345.GC4266@atlas> From: Kirill Shcherbatov Message-ID: <7846fe00-6cc0-17f6-2bdf-ab82a792f227@tarantool.org> Date: Thu, 24 May 2018 10:32:48 +0300 MIME-Version: 1.0 In-Reply-To: <20180523175345.GC4266@atlas> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Kostya Osipov , tarantool-patches@freelists.org Cc: "v.shpilevoy@tarantool.org" > While the previous callback is self-explanatory, this one requires > a comment. Actually a comment for both won't hurt. What should the > callback return? who does own the memory used by the return value? > What is the error handling convention? +/** + * Decode enum stored in MsgPack. + * @param str encoded data pointer (next to MsgPack ENUM header). + * @param len str length. + * @retval string index or hmax if the string is not found. + */ typedef int64_t (*opt_def_to_enum_cb)(const char *str, uint32_t len); + +/** + * Decode MsgPack array callback. + * All memory allocations returned by opt_def_to_array_cb with opt + * [out] argument should be managed manually. + * @param str encoded data pointer (next to MsgPack ARRAY header). + * @param len array length (items count). + * @param [out] opt pointer to store resulting value. + * @retval 0 on success. + * @retval -1 on error. + */ typedef int (*opt_def_to_array_cb)(const char **str, uint32_t len, char *opt); > The comment became worse, not better. - /** If not NULL, used to get a value by a string. */ + /** MsgPack data decode callbacks. */ > Otherwise LGTM.