Back to index

lightning-sunbird  0.9+nobinonly
mac_strings.cpp
Go to the documentation of this file.
00001 /*
00002        mac_strings.cpp
00003  */
00004 
00005 #include "mac_strings.h"
00006 
00007 #include <string.h>
00008 #include <Memory.h>
00009 #include <new>
00010 
00011 StringPtr c2p_strcpy(StringPtr pstr, const char* cstr)
00012 {
00013        size_t len = ::strlen(cstr);
00014        if (len > 255) len = 255;
00015        BlockMoveData(cstr, pstr + 1, len);
00016        pstr[0] = len;
00017        return pstr;
00018 }
00019 
00020 char* p2c_strcpy(char* cstr, const StringPtr pstr)
00021 {
00022        size_t len = pstr[0];
00023        BlockMoveData(pstr + 1, cstr, len);
00024        cstr[len] = '\0';
00025        return cstr;
00026 }
00027 
00028 char* p2c_strdup(StringPtr pstr)
00029 {
00030        size_t len = pstr[0];
00031        char* cstr = new char[1 + len];
00032        if (cstr != NULL) {
00033               BlockMoveData(pstr + 1, cstr, len);
00034               cstr[len] = '\0';
00035        }
00036        return cstr;
00037 }
00038