Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak - data tree with top level siblings #16

Closed
lukasmacko opened this issue Feb 5, 2016 · 0 comments
Closed

Memory leak - data tree with top level siblings #16

lukasmacko opened this issue Feb 5, 2016 · 0 comments
Assignees

Comments

@lukasmacko
Copy link
Contributor

#include <stdio.h>
#include <stdlib.h>
#include <libyang/libyang.h>

int main(int argc, char **argv)
{
    struct ly_ctx *ctx = ly_ctx_new(".");

    if (NULL == ly_ctx_load_module(ctx, "test-module", NULL)){
        puts("load module failed");
        return 1;
    }   
    struct lyd_node *data = lyd_parse_path(ctx, "test-module.data", LYD_XML, 0); 
    if (NULL == data){
        puts("load data failed");
        return 1;
    }   
    lyd_free_withsiblings(data);

    ly_ctx_destroy(ctx, NULL);
    return 0;
}

test-module.data

<main xmlns="urn:ietf:params:xml:ns:yang:test-module">
  <enum>maybe</enum>
  <raw>SGVsbG8gd29ybGQh</raw>
  <options>strict recursive</options>
  <dec64>9.85</dec64>
  <i8>8</i8>
  <i16>16</i16>
  <i32>32</i32>
  <i64>64</i64>
  <ui8>8</ui8>
  <ui16>16</ui16>
  <ui32>32</ui32>
  <ui64>64</ui64>
  <empty/>
  <boolean>true</boolean>
  <string>str</string>
  <id_ref>id_1</id_ref>
  <numbers>1</numbers>
  <numbers>2</numbers>
  <numbers>42</numbers>
</main>
<list xmlns="urn:ietf:params:xml:ns:yang:test-module">
  <key>k2</key>
  <id_ref>id_2</id_ref>
  <union>infinity</union>
</list>
<list xmlns="urn:ietf:params:xml:ns:yang:test-module">
  <key>k1</key>
  <id_ref>id_1</id_ref>
  <union>42</union>
  <wireless/>
</list>

test-module.yin

<?xml version="1.0" encoding="UTF-8"?>
<module name="test-module"
        xmlns="urn:ietf:params:xml:ns:yang:yin:1"
        xmlns:tm="urn:ietf:params:xml:ns:yang:test-module">
  <namespace uri="urn:ietf:params:xml:ns:yang:test-module"/>
  <prefix value="tm"/>
  <organization>
    <text>organization</text>
  </organization>
  <description>
    <text>example yang module</text>
  </description>
  <contact>
    <text>example@example.org</text>
  </contact>
  <container name="main">
    <leaf name="enum">
      <type name="enumeration">
        <enum name="yes">
          <value value="1"/>
        </enum>
        <enum name="no">
          <value value="2"/>
        </enum>
        <enum name="maybe">
          <value value="3"/>
        </enum>
      </type>
    </leaf>
    <leaf name="options">
      <type name="bits">
        <bit name="strict"/>
        <bit name="recursive"/>
        <bit name="logging"/>
      </type>
    </leaf>
    <leaf name="raw">
      <type name="binary"/>
    </leaf>
    <leaf name="dec64">
      <type name="decimal64">
        <fraction-digits value="2"/>
      </type>
    </leaf>
    <leaf name="i8">
      <type name="int8"/>
    </leaf>
    <leaf name="i16">
      <type name="int16"/>
    </leaf>
    <leaf name="i32">
      <type name="int32"/>
    </leaf>
    <leaf name="i64">
      <type name="int64"/>
    </leaf>
    <leaf name="ui8">
      <type name="uint8"/>
    </leaf>
    <leaf name="ui16">
      <type name="uint16"/>
    </leaf>
    <leaf name="ui32">
      <type name="uint32"/>
    </leaf>
    <leaf name="ui64">
      <type name="uint64"/>
    </leaf>
    <leaf name="empty">
      <type name="empty"/>
    </leaf>
    <leaf name="boolean">
      <type name="boolean"/>
    </leaf>
    <leaf name="string">
      <type name="string"/>
    </leaf>
    <leaf name="id_ref">
      <type name="identityref">
        <base name="base_id"/>
      </type>
    </leaf>
    <leaf-list name="numbers">
      <type name="uint8"/>
    </leaf-list>
  </container>
  <identity name="base_id"/>
  <identity name="id_1">
    <base name="base_id"/>
  </identity>
  <identity name="id_2">
    <base name="base_id"/>
  </identity>
  <list name="list">
    <key value="key"/>
    <leaf name="key">
      <type name="string"/>
    </leaf>
    <leaf name="id_ref">
      <type name="identityref">
        <base name="base_id"/>
      </type>
    </leaf>
    <leaf name="union">
      <type name="union">
        <type name="uint8"/>
        <type name="enumeration">
          <enum name="infinity"/>
        </type>
      </type>
    </leaf>
    <container name="wireless">
      <presence value="wireless is enabled"/>
      <leaf name="vendor_name">
        <type name="string"/>
      </leaf>
    </container>
  </list>
</module>
@rkrejci rkrejci self-assigned this Feb 5, 2016
@rkrejci rkrejci closed this as completed in 044a8da Feb 5, 2016
rkrejci added a commit that referenced this issue Feb 5, 2016
PavolVican pushed a commit that referenced this issue Feb 9, 2016
alangefe pushed a commit to ADTRAN/libyang that referenced this issue Aug 7, 2018
Since sysrepo does not supposrt to set leafref directly, we have to Resolve
leafref node to its target and set the leafref node with its target type.

Fixes CESNET#16
alangefe pushed a commit to ADTRAN/libyang that referenced this issue Aug 7, 2018
Since sysrepo does not supposrt to set leafref directly, we have to Resolve
leafref node to its target and set the leafref node with its target type.

Fixes CESNET#16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants