Skip to content

Commit

Permalink
Remove PDC_CALLOC and PDC_FREE macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyunju Oh committed Dec 14, 2023
1 parent cf2a1b1 commit 25759d1
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 99 deletions.
6 changes: 3 additions & 3 deletions src/api/pdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ PDCinit(const char *pdc_name)

FUNC_ENTER(NULL);

if (NULL == (pdc_id_list_g = PDC_CALLOC(1, struct pdc_id_list)))
if (NULL == (pdc_id_list_g = (struct pdc_id_list *)PDC_calloc(1, sizeof(struct pdc_id_list))))
PGOTO_ERROR(FAIL, "PDC global id list: memory allocation failed");

if (PDC_class_init() < 0)
Expand Down Expand Up @@ -130,7 +130,7 @@ PDC_class__close(struct _pdc_class *p)
#endif

free(p->name);
p = PDC_FREE(struct _pdc_class, p);
p = (struct _pdc_class *)(intptr_t) PDC_free(p);

FUNC_LEAVE(ret_value);
}
Expand Down Expand Up @@ -214,7 +214,7 @@ PDCclose(pdcid_t pdcid)

PDC_class_end();

pdc_id_list_g = PDC_FREE(struct pdc_id_list, pdc_id_list_g);
pdc_id_list_g = (struct pdc_id_list *)(intptr_t) PDC_free(pdc_id_list_g);

// Finalize METADATA
PDC_Client_finalize();
Expand Down
30 changes: 15 additions & 15 deletions src/api/pdc_obj/pdc_cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ PDCcont_create(const char *cont_name, pdcid_t cont_prop_id)
id_info = PDC_find_id(cont_prop_id);
cont_prop = (struct _pdc_cont_prop *)(id_info->obj_ptr);

p->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop);
p->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop));
if (!p->cont_pt)
PGOTO_ERROR(0, "PDC container prop memory allocation failed");
memcpy(p->cont_pt, cont_prop, sizeof(struct _pdc_cont_prop));

p->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class);
p->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class));
if (!p->cont_pt->pdc)
PGOTO_ERROR(0, "PDC container pdc class memory allocation failed");
if (cont_prop->pdc->name)
Expand Down Expand Up @@ -121,12 +121,12 @@ PDCcont_create_col(const char *cont_name, pdcid_t cont_prop_id)
id_info = PDC_find_id(cont_prop_id);
cont_prop = (struct _pdc_cont_prop *)(id_info->obj_ptr);

p->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop);
p->cont_pt =(struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop));
if (!p->cont_pt)
PGOTO_ERROR(0, "PDC container prop memory allocation failed");
memcpy(p->cont_pt, cont_prop, sizeof(struct _pdc_cont_prop));

p->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class);
p->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class));
if (!p->cont_pt->pdc)
PGOTO_ERROR(0, "PDC container pdc class memory allocation failed");
if (cont_prop->pdc->name)
Expand Down Expand Up @@ -170,12 +170,12 @@ PDC_cont_create_local(pdcid_t pdc, const char *cont_name, uint64_t cont_meta_id)

id_info = PDC_find_id(cont_prop_id);
cont_prop = (struct _pdc_cont_prop *)(id_info->obj_ptr);
p->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop);
p->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop));
if (!p->cont_pt)
PGOTO_ERROR(0, "PDC container prop memory allocation failed");
memcpy(p->cont_pt, cont_prop, sizeof(struct _pdc_cont_prop));

p->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class);
p->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class));
if (!p->cont_pt->pdc)
PGOTO_ERROR(0, "PDC container pdc class memory allocation failed");

Expand Down Expand Up @@ -221,11 +221,11 @@ PDC_cont_close(struct _pdc_cont_info *cp)
FUNC_ENTER(NULL);

free((void *)(cp->cont_info_pub->name));
cp->cont_info_pub = PDC_FREE(struct pdc_cont_info, cp->cont_info_pub);
cp->cont_info_pub = (struct pdc_cont_info *)(intptr_t) PDC_free(cp->cont_info_pub);
free(cp->cont_pt->pdc->name);
cp->cont_pt->pdc = PDC_FREE(struct _pdc_class, cp->cont_pt->pdc);
cp->cont_pt = PDC_FREE(struct _pdc_cont_prop, cp->cont_pt);
cp = PDC_FREE(struct _pdc_cont_info, cp);
cp->cont_pt->pdc = (struct _pdc_class *)(intptr_t) PDC_free(cp->cont_pt->pdc);
cp->cont_pt = (struct _pdc_cont_prop *)(intptr_t) PDC_free(cp->cont_pt);
cp = (struct _pdc_cont_info *)(intptr_t) PDC_free(cp);

FUNC_LEAVE(ret_value);
}
Expand Down Expand Up @@ -318,13 +318,13 @@ PDC_cont_get_info(pdcid_t cont_id)
id_info = PDC_find_id(cont_id);
info = (struct _pdc_cont_info *)(id_info->obj_ptr);

ret_value = PDC_CALLOC(1, struct _pdc_cont_info);
ret_value = (struct _pdc_cont_info *)PDC_calloc(1, sizeof(struct _pdc_cont_info));
if (ret_value)
memcpy(ret_value, info, sizeof(struct _pdc_cont_info));
else
PGOTO_ERROR(NULL, "cannot allocate ret_value");

ret_value->cont_info_pub = PDC_CALLOC(1, struct pdc_cont_info);
ret_value->cont_info_pub = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info));
if (ret_value->cont_info_pub)
memcpy(ret_value, info, sizeof(struct pdc_cont_info));
else
Expand All @@ -337,7 +337,7 @@ PDC_cont_get_info(pdcid_t cont_id)
memcpy(ret_value->cont_pt, info->cont_pt, sizeof(struct _pdc_cont_prop));
else
PGOTO_ERROR(NULL, "cannot allocate ret_value->cont_pt");
ret_value->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class);
ret_value->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class));
if (ret_value->cont_pt->pdc) {
ret_value->cont_pt->pdc->local_id = info->cont_pt->pdc->local_id;
if (info->cont_pt->pdc->name)
Expand All @@ -364,7 +364,7 @@ PDCcont_get_info(const char *cont_name)

tmp = PDC_cont_get_info(cont_id);

ret_value = PDC_CALLOC(1, struct pdc_cont_info);
ret_value = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info));
if (!ret_value)
PGOTO_ERROR(NULL, "cannot allocate memory");

Expand Down Expand Up @@ -438,7 +438,7 @@ PDCcont_iter_get_info(cont_handle *chandle)
if (info == NULL)
PGOTO_ERROR(NULL, "PDC container info memory allocation failed");

ret_value = PDC_CALLOC(1, struct pdc_cont_info);
ret_value = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info));
if (!ret_value)
PGOTO_ERROR(NULL, "failed to allocate memory");

Expand Down
Loading

0 comments on commit 25759d1

Please sign in to comment.