From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CLaVFfAT5mXyAgAAbAwnHQ (envelope-from ) for ; Mon, 04 Mar 2024 19:33:20 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id EAbqDvAT5mVzQAEA62LTzQ (envelope-from ) for ; Mon, 04 Mar 2024 19:33:20 +0100 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; none Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2A162457E4 for ; Mon, 4 Mar 2024 19:33:17 +0100 (CET) DKIM-Signature: a=rsa-sha256; bh=MTaaNXZhizWbedlEeDCZ9K5pT1tYeCDpFdmfyYZLtKA=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1709577196; v=1; b=EK3u1XQQwCJop4Hfd3s2cMV9cBTEnnfr7ng6kqtt5axJHXdkaz8e8crLq+IRDgxhkvBgjxuU f8KoRVyrNZpAYL1F8omYCLMvQWhscUPi47snvjyRzvImqdXIs9YvMOEe7V0l0Fd6V5sCnP6DjXB BlQ+xl/Aj7oo/+9m8DLTnEjvXoQRUCOOogTdY+JRNRC0A9dN5IZPaG8NpSzTC66Jbl+vMX+A9cw 0a5c7vHwpc5xdPzBu7Fwu/VWZXReCcOHuAJiR83S2RMlA41HZqh825BsCurheil5EML/BO6g7La OnoUrE+lbgewRZybH7ayEIOkwkhe4fvRFw461ymOO7n4w== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 1214D20164 for ; Mon, 4 Mar 2024 18:33:16 +0000 (UTC) Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) by mail-a.sr.ht (Postfix) with ESMTPS id 7AB5620154 for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 4 Mar 2024 18:33:15 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1709577195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=scUvX3JTWNsWVfkG9C0nuGcp2aAu5sLhclwxcK/Q2e8=; b=Rf1nMsbzAp1zzOcsX70xDHERYC2UYOU+gV0IRIiaOUb4OOHz7tJ9K/ImXeoiq4oMgGTxCC gTQvxWkSQg8zO2+QahkDg8peQNn06u51uj2bGSaIv+Hf5frNXOyQQVzfUVxCJgquDTDwZx 2sCeT8Fc+USyivxCB95FjJzbtVqA2LTqlmO+qseJgIKTTBtBcvnxFQlp1z8E3p0JnSO6VE +bMDZupeL++G1nUE+wRz+/+Q71e3Vt4h3B7uXEYAChZ3lbeJuTml49ArBPZahAviH2SQa5 ziR27zr8ee7g7dfzgkxIaj+kOgLahsmV2+ZsFcX/Cgj87DpidkTM+9jfqowL1Q== From: Johnny Richard To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Johnny Richard Subject: [PATCH olang v1 2/3] string_view: add function to create from cstr Date: Mon, 4 Mar 2024 20:23:11 +0100 Message-ID: <20240304193313.961286-3-johnny@johnnyrichard.com> In-Reply-To: <20240304193313.961286-1-johnny@johnnyrichard.com> References: <20240304193313.961286-1-johnny@johnnyrichard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Sourcehut-Patchset-Status: UNKNOWN List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Spam-Score: -4.00 X-Spam-Score: -4.00 X-Migadu-Queue-Id: 2A162457E4 X-Migadu-Scanner: mx13.migadu.com X-TUID: RFHSJbPwdlMf Signed-off-by: Johnny Richard --- src/string_view.c | 6 ++++++ src/string_view.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/string_view.c b/src/string_view.c index 646dabd..b4d4103 100644 --- a/src/string_view.c +++ b/src/string_view.c @@ -21,6 +21,12 @@ #include #include +string_view_t +string_view_from_cstr(char *cstr) +{ + return (string_view_t){ .chars = cstr, .size = strlen(cstr) }; +} + bool string_view_eq_to_cstr(string_view_t str, char *cstr) { diff --git a/src/string_view.h b/src/string_view.h index d5d2e6c..0a3654f 100644 --- a/src/string_view.h +++ b/src/string_view.h @@ -31,6 +31,9 @@ typedef struct string_view } string_view_t; +string_view_t +string_view_from_cstr(char *cstr); + bool string_view_eq_to_cstr(string_view_t str, char *cstr); -- 2.44.0