Changeset 3 in Main for trunk/Common


Ignore:
Timestamp:
Sep 13, 2024, 6:06:44 PM (2 months ago)
Author:
Nishi
Message:

string op works, log works too

Location:
trunk/Common
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Makefile

    r2 r3  
    66.SUFFIXES: .c .o
    77
    8 OBJS = string.o
     8OBJS = string.o log.o
    99
    1010all: common.a
  • trunk/Common/string.c

    r2 r3  
    11/* $Id$ */
     2
     3#include <string.h>
     4#include <stdlib.h>
     5
     6char* cm_strcat(const char* a, const char* b) {
     7        char* str = malloc(strlen(a) + strlen(b) + 1);
     8        memcpy(str, a, strlen(a));
     9        memcpy(str + strlen(a), b, strlen(b));
     10        str[strlen(a) + strlen(b)] = 0;
     11        return str;
     12}
     13
     14char* cm_strdup(const char* str) { return cm_strcat(str, ""); }
Note: See TracChangeset for help on using the changeset viewer.