Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2005, 4:24:50 PM (18 years ago)
Author:
rennerc
Message:

converter: added function which allocates momory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/synchronizeable.h

    r6277 r6285  
    2929 * with the same argument names!
    3030 *
     31 * SYNCHELP_WRITE_BEGIN()
     32 * SYNCHELP_WRITE_INT(i)
     33 * SYNCHELP_WRITE_FLOAT(f)
     34 * SYNCHELP_WRITE_BYTE(b)
     35 * SYNCHELP_WRITE_STRING(s)
     36 * SYNCHELP_WRITE_N
     37 *
     38 * SYNCHELP_READ_BEGIN()
     39 * SYNCHELP_READ_INT(i)
     40 * SYNCHELP_READ_FLOAT(f)
     41 * SYNCHELP_READ_STRING(s,l) l = size of buffer s
     42 * SYNCHELP_READ_STRINGM(s)  allocates memory for string! you have to free this after
     43 * SYNCHELP_READ_BYTE(b)
     44 *
     45 *
    3146 *
    3247 * Example 1:
     
    4459#define SYNCHELP_WRITE_BEGIN()    int __synchelp_write_i = 0; \
    4560                                  int __synchelp_write_n
    46 #define SYNCHELP_WRITE_RESET() { __synchelp_write_i = 0; __synchelp_write_err = false; }
    4761#define SYNCHELP_WRITE_INT(i) { __synchelp_write_n = \
    4862                                Converter::intToByteArray( i, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
     
    112126                                    __synchelp_read_i += __synchelp_read_n; \
    113127}
     128#define SYNCHELP_READ_STRINGM(s)    { \
     129                                    __synchelp_read_n = Converter::byteArrayToStringM( data+__synchelp_read_i, s );  \
     130                                    if ( __synchelp_read_n <0 )  \
     131{ \
     132                                      PRINTF(1)("There is not enough data to read string\n");  \
     133                                      return; \
     134} \
     135                                    __synchelp_read_i += __synchelp_read_n; \
     136}
    114137#define SYNCHELP_READ_BYTE(b)      { \
    115138                                    if ( length-__synchelp_read_i < 1 ) \
Note: See TracChangeset for help on using the changeset viewer.