Add Elf/Phdr/Scn alloc/destroy
[centaur.git] / src / libelfu / model / phdr.c
index ce395ec2b5e78999ec76040e126a4b9dd42f72db..6896845f482bd8aac3b5c97aea48255e119a0c2f 100644 (file)
@@ -60,3 +60,22 @@ ElfuPhdr* elfu_mPhdrAlloc()
 
   return mp;
 }
+
+void elfu_mPhdrDestroy(ElfuPhdr* mp)
+{
+  ElfuPhdr *mp2;
+  ElfuScn *ms;
+
+  assert(mp);
+
+  CIRCLEQ_FOREACH(mp2, &mp->childPhdrList, elem) {
+    // TODO ?
+  }
+
+  CIRCLEQ_FOREACH(ms, &mp->childScnList, elem) {
+    CIRCLEQ_REMOVE(&mp->childScnList, ms, elem);
+    elfu_mScnDestroy(ms);
+  }
+
+  free(mp);
+}