Changes between Version 1 and Version 2 of C++ API

Show
Ignore:
Timestamp:
09/07/12 17:50:05 (12 years ago)
Author:
jorisborgdorff
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • C++ API

    v1 v2  
    4040 
    4141The type {{{MUSCLE_COMPLEX}}} is only available for C++ code. 
     42 
     43Receiving a message can be done in two ways: either the memory is initialized beforehand and the buffer size is given as the third argument, or a 0 pointer is passed, in which case MUSCLE will initialize the memory. In both cases, the memory must be freed by the user. For example: 
     44{{{ 
     45size_t sz = 100; 
     46double *data = (double *)malloc(sz*sizeof(double)); 
     47if (data) { 
     48    for (int i = 0; !MUSCLE_Will_Stop(); i++) { 
     49    MUSCLE_Receive("exitName", data, &sz, MUSCLE_DOUBLE); 
     50    // do something with the data 
     51} 
     52free(data); 
     53}}} 
     54or 
     55{{{ 
     56size_t sz = 0; 
     57if (data) { 
     58    for (int i = 0; !MUSCLE_Will_Stop(); i++) { 
     59    double *data = (double *)MUSCLE_Receive("exitName", (void *)0, &sz, MUSCLE_DOUBLE); 
     60    // do something with the data 
     61    // data will have length sz; 
     62    free(data); 
     63} 
     64}}}