From: Peter Johnson Date: Wed, 13 Jun 2001 05:24:50 +0000 (-0000) Subject: Initial check-in of utility functions. X-Git-Tag: v0.1.0~462 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2141d4f43ddbdbcf2c0150dbe59e8ab34e7db62d;p=yasm Initial check-in of utility functions. svn path=/trunk/yasm/; revision=49 --- diff --git a/include/util.h b/include/util.h new file mode 100644 index 00000000..33377ab9 --- /dev/null +++ b/include/util.h @@ -0,0 +1,27 @@ +/* $Id: util.h,v 1.1 2001/06/13 05:24:50 peter Exp $ + * Various utility functions for ANSI C compatibility header file + * + * Copyright (C) 2001 Peter Johnson + * + * This file is part of YASM. + * + * YASM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * YASM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +char *y_strdup(char *str); + +#endif diff --git a/libyasm/util.h b/libyasm/util.h new file mode 100644 index 00000000..33377ab9 --- /dev/null +++ b/libyasm/util.h @@ -0,0 +1,27 @@ +/* $Id: util.h,v 1.1 2001/06/13 05:24:50 peter Exp $ + * Various utility functions for ANSI C compatibility header file + * + * Copyright (C) 2001 Peter Johnson + * + * This file is part of YASM. + * + * YASM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * YASM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +char *y_strdup(char *str); + +#endif diff --git a/src/util.c b/src/util.c new file mode 100644 index 00000000..52496ccd --- /dev/null +++ b/src/util.c @@ -0,0 +1,36 @@ +/* $Id: util.c,v 1.1 2001/06/13 05:24:50 peter Exp $ + * Various utility functions for ANSI C compatibility + * + * Copyright (C) 2001 Peter Johnson + * + * This file is part of YASM. + * + * YASM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * YASM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include "util.h" + +char *y_strdup(char *str) +{ + size_t len; + char *copy; + + len = strlen(str) + 1; + if((copy = malloc(len)) == NULL) + return (char *)NULL; + memcpy(copy, str, len); + return copy; +} diff --git a/src/util.h b/src/util.h new file mode 100644 index 00000000..33377ab9 --- /dev/null +++ b/src/util.h @@ -0,0 +1,27 @@ +/* $Id: util.h,v 1.1 2001/06/13 05:24:50 peter Exp $ + * Various utility functions for ANSI C compatibility header file + * + * Copyright (C) 2001 Peter Johnson + * + * This file is part of YASM. + * + * YASM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * YASM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +char *y_strdup(char *str); + +#endif diff --git a/util.h b/util.h new file mode 100644 index 00000000..33377ab9 --- /dev/null +++ b/util.h @@ -0,0 +1,27 @@ +/* $Id: util.h,v 1.1 2001/06/13 05:24:50 peter Exp $ + * Various utility functions for ANSI C compatibility header file + * + * Copyright (C) 2001 Peter Johnson + * + * This file is part of YASM. + * + * YASM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * YASM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +char *y_strdup(char *str); + +#endif