Hello,
I am trying to use the GMT API to develop some external tools. When I want to get the coast lines, these simple instructions work like a charm:
API = GMT_Create_Session(“GMT_coast”, 2, 0, NULL);
GMT_Open_VirtualFile(API, GMT_IS_DATASET, GMT_IS_PLP, GMT_OUT, NULL, output);
GMT_Call_Module(API, “coast”, argc, argv);
D = GMT_Read_VirtualFile(API, output);
I get exactly what I need in the dataset structure D.
But when I want to get palette colors, this way:
API = GMT_Create_Session(“GMT_makecpt”, 2, 0, NULL);
GMT_Open_VirtualFile(API, GMT_IS_PALETTE, GMT_IS_NONE, GMT_OUT, NULL, output);
GMT_Call_Module(API, “makecpt”, argc, argv);
P = GMT_Read_VirtualFile(API, output);
I cannot even reach the last line, the call to makecpt aborts into gmtlib_copy_palette. Therefore, it seems like I must allocate the palette structure before calling the module, while it was not needed for coast.
Can anybody confirm this? And is there a mean to decide if I have to allocate memory first or not? Is there best practices?
Thanks, regards,
Olivier