Module: kamailio
Branch: master
Commit: b92b931c26c199b756fd08e9c80cc9305469fd2b
URL: https://github.com/kamailio/kamailio/commit/b92b931c26c199b756fd08e9c80cc93…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-06-29T08:55:32+02:00
core: str list - added function to insert a block string in list
---
Modified: src/core/str_list.c
Modified: src/core/str_list.h
---
Diff: https://github.com/kamailio/kamailio/commit/b92b931c26c199b756fd08e9c80cc93…
Patch: https://github.com/kamailio/kamailio/commit/b92b931c26c199b756fd08e9c80cc93…
---
diff --git a/src/core/str_list.c b/src/core/str_list.c
index f63b4c9151..207cee5bc3 100644
--- a/src/core/str_list.c
+++ b/src/core/str_list.c
@@ -13,13 +13,13 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
- * @file
+ * @file
* @brief Kamailio core :: Simple str type list and helper functions
* @ingroup core
* Module: @ref core
@@ -32,7 +32,7 @@
/**
* @brief Add a new allocated list element to an existing list
- *
+ *
* Add a new allocated list element to an existing list, the allocation is done
* from the private memory pool
* @param s input character
@@ -43,18 +43,45 @@
*/
struct str_list *append_str_list(char *s, int len, struct str_list **last, int *total)
{
- struct str_list *new;
- new = pkg_malloc(sizeof(struct str_list));
- if (!new) {
+ struct str_list *nv;
+ nv = pkg_malloc(sizeof(struct str_list));
+ if (!nv) {
PKG_MEM_ERROR;
return 0;
}
- new->s.s = s;
- new->s.len = len;
- new->next = 0;
+ nv->s.s = s;
+ nv->s.len = len;
+ nv->next = 0;
- (*last)->next = new;
- *last = new;
+ (*last)->next = nv;
+ *last = nv;
*total += len;
- return new;
+ return nv;
+}
+
+/**
+ * @brief Add a new allocated list element with cloned block value to an existing list
+ *
+ * Add a new allocated list element with cloned value in block to an existing list,
+ * the allocation is done from the private memory pool
+ * @param head existing list
+ * @param s input character
+ * @param len length of input character
+ * @return extended list
+ */
+str_list_t *str_list_block_add(str_list_t **head, char *s, int len)
+{
+ str_list_t *nv;
+ nv = pkg_mallocxz(sizeof(str_list_t) + (len+1)*sizeof(char));
+ if (!nv) {
+ PKG_MEM_ERROR;
+ return 0;
+ }
+ nv->s.s = (char*)nv + sizeof(str_list_t);
+ memcpy(nv->s.s, s, len);
+ nv->s.len = len;
+ nv->next = *head;
+ *head = nv;
+
+ return nv;
}
diff --git a/src/core/str_list.h b/src/core/str_list.h
index db3fa12887..1eac2578b0 100644
--- a/src/core/str_list.h
+++ b/src/core/str_list.h
@@ -51,4 +51,16 @@ typedef struct str_list {
*/
struct str_list *append_str_list(char *s, int len, struct str_list **last, int *total);
+/**
+ * @brief Add a new allocated list element with cloned block value to an existing list
+ *
+ * Add a new allocated list element with cloned value in block to an existing list,
+ * the allocation is done from the private memory pool
+ * @param head existing list
+ * @param s input character
+ * @param len length of input character
+ * @return extended list
+ */
+str_list_t *str_list_block_add(str_list_t **head, char *s, int len);
+
#endif
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
New Module to consume messages from NATS messaging system.
Initial Features:
- automatic reconnect with connected/disconnected event routes
- connect to up to 10 NATS URLs
- subscribe to any number of subjects
- receive messages via event route
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/2790
-- Commit Summary --
* nats: new nats message consumer module
-- File Changes --
A src/modules/nats/Makefile (16)
A src/modules/nats/doc/Makefile (4)
A src/modules/nats/doc/nats.xml (42)
A src/modules/nats/doc/nats_admin.xml (207)
A src/modules/nats/nats_mod.c (569)
A src/modules/nats/nats_mod.h (99)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2790.patchhttps://github.com/kamailio/kamailio/pull/2790.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2790