Sha256: b123adeb74e95a0f49540f79b1d78bcf1829e9c3626383bc592ba7928e084ad2

Contents?: true

Size: 574 Bytes

Versions: 3

Compression:

Stored size: 574 Bytes

Contents

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "string_extras.h"

void remove_last_char(char* str)
{
  size_t len = strlen(str);
  str[len - 1] = '\0';
}

void remove_first_char(char* str)
{
  size_t len = strlen(str);
  memmove(str, str + 1, len);
}

char *dupe_string(const char * str)
{
  int len = strlen(str) + 1;
  char *buf = malloc(len);
  if (buf) { memcpy(buf, str, len); }
  return buf;
}

char *dupe_string_n(const char *s, size_t n)
{
  char* buf = malloc(n + 1);
  if (buf) {
    strncpy(buf, s, n);
    buf[n] = '\0';
  }
  return buf;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mathematical-0.6.2 ext/mathematical/mtex2MML/src/string_extras.c
mathematical-0.6.1 ext/mathematical/mtex2MML/src/string_extras.c
mathematical-0.6.0 ext/mathematical/mtex2MML/src/string_extras.c