HPCToolkit
generic_pair.c
Go to the documentation of this file.
1 /*
2  * generic_pair.c
3  *
4  * Author: dxnguyen
5  */
6 
7 //******************************************************************************
8 // global include files
9 //******************************************************************************
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 
15 //******************************************************************************
16 // local include files
17 //******************************************************************************
18 #include "generic_pair.h"
19 
20 
22 generic_pair_t_new(void* first, void* second, mem_alloc m_alloc)
23 {
24  generic_pair_t* genpair = (generic_pair_t*)m_alloc(sizeof(generic_pair_t));
25  genpair->first = first;
26  genpair->second = second;
27  return genpair;
28 }
29 
30 void
32  val_tostr first_tostr, char firststr[],
33  val_tostr second_tostr, char secondstr[], char str[])
34 {
35  if (gen_pair) {
36  first_tostr(gen_pair->first, firststr);
37  second_tostr(gen_pair->second, secondstr);
38  snprintf(str, strlen(firststr) + strlen(secondstr) + 6, "%s%s%s%s%s",
39  "(", firststr, ", ", secondstr, ")");
40  }
41  else {
42  strcpy(str, "");
43  }
44 }
void generic_pair_t_tostr(generic_pair_t *gen_pair, val_tostr first_tostr, char firststr[], val_tostr second_tostr, char secondstr[], char str[])
Definition: generic_pair.c:31
void *(* mem_alloc)(size_t size)
Definition: mem_manager.h:17
void(* val_tostr)(void *val, char str[])
Definition: generic_val.h:22
generic_pair_t * generic_pair_t_new(void *first, void *second, mem_alloc m_alloc)
Definition: generic_pair.c:22