api refactoring
[m6w6/ext-psi] / src / types / let_calloc.h
diff --git a/src/types/let_calloc.h b/src/types/let_calloc.h
new file mode 100644 (file)
index 0000000..e6d3f91
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef _PSI_TYPES_LET_CALLOC_H
+#define _PSI_TYPES_LET_CALLOC_H
+
+typedef struct let_calloc {
+       num_exp *nmemb;
+       num_exp *size;
+} let_calloc;
+
+static inline let_calloc *init_let_calloc(num_exp *nmemb, num_exp *size) {
+       let_calloc *alloc = calloc(1, sizeof(*alloc));
+       alloc->nmemb = nmemb;
+       alloc->size = size;
+       return alloc;
+}
+
+static inline void free_let_calloc(let_calloc *alloc) {
+       free_num_exp(alloc->nmemb);
+       free_num_exp(alloc->size);
+       free(alloc);
+}
+
+#endif